当我将连接的组件export default connect(ComponentName)
传递到React Route route
时,如下面的代码,
<Route path={path} component={ComponentName}/>
我收到以下错误,
You must pass a component to the function returned by connect.
Instead received {"match":{"path":"/:code","url":"/sample-
code","isExact":true,"params":{"code":"sample-code"}},"location":
{"pathname":"/sample-code","search":"","hash":""},"history":
{"length":40,"action":"POP","location":{"pathname":"/sample-
code","search":"","hash":""}}}
我可以将连接的组件传递给route
组件吗?
答案 0 :(得分:4)
connect
将mapStateToProps
等函数作为其参数。你可能意味着connect()(ComponentName)
。
您绝对可以将连接的组件传递到具有component
道具的路线,而无需使用render
道具。