我正在尝试从connect创建类似于react-redux的高阶组件(HOC),但是遇到了错误。

我的代码可以在这里找到:
https://codesandbox.io/s/483or78no0

我从以下博客文章中获取了此HOC代码:
https://medium.com/@franleplant/react-higher-order-components-in-depth-cf9032ee6c3e(查找Appendix A: HOC and parameters)

我得到的错误是:Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.而没有呈现任何内容。

最佳答案

您应该在render函数中使用jsx标记:

render(<App/>, document.getElementById('root'));

关于javascript - 尝试使用返回返回HOC的函数的错误(la Redux Connect),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46837134/

10-13 01:46