【问题标题】:Functions are not valid as a React child. This may happen if you return a Component instead of from render. Redux函数作为 React 子级无效。如果您返回一个组件而不是从渲染中返回,则可能会发生这种情况。还原
【发布时间】:2022-01-19 21:52:27
【问题描述】:

我正在使用 react-redux,我使用无状态组件

The error

This is my index.js

My app.js

the store is in another index.js file, inside a folder called redux

我已经尝试过NewHOC,但我无法摆脱错误

【问题讨论】:

标签: javascript reactjs redux react-redux


【解决方案1】:

我相信你已经看过this question,因为你提到了“NewHOC”。

考虑到这一点,请确保在所有组件中使用 return 语句(如果它们是 functional components),或者如果它们是基于类的组件则使用渲染方法。

根据您的屏幕截图,RouterDirectory 似乎是罪魁祸首,因为您上传的屏幕截图看起来不错,但我们看不到 RouterDirectory。

如果您可以提供RouterDirectory 的代码,我们可以进一步帮助您。

【讨论】:

    猜你喜欢
    • 2018-12-01
    • 2018-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-20
    • 2018-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多