会在带有开关的组件内触发"/>
调度不会在带有开关的组件内触发
我在我的应用程序组件上有此]
import React, { useEffect } from 'react'; import './App.css' import Routes from './routes' import { useDispatch, connect } from 'react-redux' import { store } from './index' import { loadUser } from './actions/authActions' function App() { const dispatch = useDispatch() useEffect(() => { dispatch(loadUser()) // eslint-disable-next-line react-hooks/exhaustive-deps }) return ( <div className="App"> <Routes /> </div> ); } export default App;
此分派验证用户令牌,但是在我有一个的路线上,它根本无法工作触发,(即使我将useEffect函数直接放在有问题的组件上)
我在我的应用程序组件上将其导入React,{useEffect} from'react';从'./routes'导入路由'./app.css'从'./routes'导入路由{useDispatch,connect}从'react-redux'导入{store}从'....
回答如下:更多推荐
调度不会在带有开关的组件内触发
发布评论