【发布时间】:2020-08-08 12:06:59
【问题描述】:
我正在尝试传递我自己的自定义道具(函数、对象 ..etc),但它们没有传递,当我在没有 gatsby 的情况下尝试 @reach/router 时它可以正常工作。
我的 app.js:
<Router basepath="">
<Welcome path="" />
<OtherComponent
path="/comppath"
myprop="prop data"
/>
</Router>
我的 OtherComponent.js
export default function OtherComponent(props){
return (
<div>
<h1>My Component</h1>
{props.myprop}
</div>
);
}
组件渲染良好,但我的道具没有通过,当我控制台记录道具时,我只得到路径、位置、pageContext 和导航方法..etc,但没有得到我的道具
旁注:我正在使用 gatsby 的 gatsby-plugin-create-client-paths
【问题讨论】:
标签: gatsby reach-router gatsby-plugin