Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs React私有路由和钩子上下文和reducer_Reactjs_React Router_React Hooks - Fatal编程技术网

Reactjs React私有路由和钩子上下文和reducer

Reactjs React私有路由和钩子上下文和reducer,reactjs,react-router,react-hooks,Reactjs,React Router,React Hooks,我尝试用私有路由实现Auth,用useReducer和Context实现hook。当我在仪表板上尝试ti路线时,我得到一个错误 Cannot read property 'isAuthenticated' of undefined 为什么??我在stackblitz上的密码 你能帮我吗? 非常感谢你。 Marco.Italy您混合了提供者/消费者和钩子组件。下面是一个更新的示例,它引入了useAuthhook

我尝试用私有路由实现Auth,用useReducer和Context实现hook。当我在仪表板上尝试ti路线时,我得到一个错误

Cannot read property 'isAuthenticated' of undefined
为什么??我在stackblitz上的密码

你能帮我吗? 非常感谢你。
Marco.Italy

您混合了提供者/消费者和钩子组件。下面是一个更新的示例,它引入了
useAuth
hook