Reactjs 如何使用redux react hook连接的react路由器
我是react新手,我想使用react钩子和redux(使用redux react钩子)进行路由(我使用连接的react路由器,但我可以切换到另一个库) 我将存储传递给StoreContext提供程序,一切正常,但是当我添加具有正确上下文的ConnectedRouter时,会出现错误 这就是我正在尝试的Reactjs 如何使用redux react hook连接的react路由器,reactjs,react-redux,connected-react-router,redux-react-hook,Reactjs,React Redux,Connected React Router,Redux React Hook,我是react新手,我想使用react钩子和redux(使用redux react钩子)进行路由(我使用连接的react路由器,但我可以切换到另一个库) 我将存储传递给StoreContext提供程序,一切正常,但是当我添加具有正确上下文的ConnectedRouter时,会出现错误 这就是我正在尝试的 //index.js import { Route, Switch } from 'react-router-dom'; import { ConnectedRouter } from 'con
//index.js
import { Route, Switch } from 'react-router-dom';
import { ConnectedRouter } from 'connected-react-router';
import { StoreContext, store, history } from './store';
ReactDOM.render((
<StoreContext.Provider value={store}>
<ConnectedRouter history={history} context={StoreContext}>
<Switch>
<Route path="/" component={App}></Route>
</Switch>
</ConnectedRouter>
</StoreContext.Provider>
), document.getElementById('root'));
但我收到了这个错误:
TypeError: sourceSelector is not a function
Connect.selectDerivedProps
C:/Users/NG7F61C/Documents/PROJECTS/1 - IJET/Sources/frontend/node_modules/react-redux/es/components/connectAdvanced.js:112
109 |
110 | lastProps = props;
111 | lastState = state;
> 112 | var nextProps = sourceSelector(state, props);
| ^ 113 | lastDerivedProps = nextProps;
114 | return lastDerivedProps;
115 | };
我是否做错了什么,或者ConnectedRouter与redux react hook不兼容?您现在是否已对其进行排序?我开始使用react redux,使用HOC的老方法。现在,我想尝试一下react-redux的钩子方式,并需要指针。@Eniola我完全放弃了使用redux。我发现用钩子完全没用了
TypeError: sourceSelector is not a function
Connect.selectDerivedProps
C:/Users/NG7F61C/Documents/PROJECTS/1 - IJET/Sources/frontend/node_modules/react-redux/es/components/connectAdvanced.js:112
109 |
110 | lastProps = props;
111 | lastState = state;
> 112 | var nextProps = sourceSelector(state, props);
| ^ 113 | lastDerivedProps = nextProps;
114 | return lastDerivedProps;
115 | };