Uncaught TypeError: Cannot destructure property 'recipes' of 'props' as it is undefined

Uncaught TypeError: Cannot destructure property 'recipes' of 'props' as it is undefined

我是 reactjs 的初学者,当我尝试 运行 一个程序时它显示了以下错误

Uncaught TypeError: Cannot destructure property 'recipes' of 'props' as it is undefined.
    at RecipeList (bundle.js:532:5)
    at renderWithHooks (bundle.js:22834:22)
    at mountIndeterminateComponent (bundle.js:25596:17)
    at beginWork (bundle.js:26795:20)
    at HTMLUnknownElement.callCallback (bundle.js:11784:18)
    at Object.invokeGuardedCallbackDev (bundle.js:11833:20)
    at invokeGuardedCallback (bundle.js:11893:35)
    at beginWork (bundle.js:31635:11)
    at performUnitOfWork (bundle.js:30471:16)
    at workLoopSync (bundle.js:30408:9)

也许您在代码中使用了 const { recipes } = props,但是 props 未定义,所以您得到错误 destructure property.

你能把你的代码放在那里吗?并检查道具是否未定义。检查父组件向子组件发送有用的数据。

您的一项分配未正确转移到组件,这就是它“未定义”的原因。

上传与此 props 代码相关的部分代码,或者使用 console.log(props) 自己尝试:检查已定义的内容和未定义的内容。 然后把两者连接起来。