问题描述
这是一个发送框 https://codesandbox.io/s/busy-euler-7mpi7?file=/src/main.js
如你所见,它给了我错误。我想要做的是在 main.js 中连接 Redux 商店。如果您删除 main.js 中的 connect
并保持组件不变,它将正常工作。但是一旦你在 main.js 中使用 connect
,它就会破坏 React 应用程序。连接时我做错了什么?
解决方法
问题在于你在 routes.js 中的对象
{
url: "/",component: Main,exact: true
}
这里,Main 不代表一个有利于传递给 Route Element 的组件。 (可能是wrapping后连接返回结构不同)
尝试将其更改为
{
url: "/",component: <Main/>,exact: true
}
它会起作用。