调度不会在带有开关的组件内触发

编程入门 行业动态 更新时间:2024-10-09 09:18:55

调度不<a href=https://www.elefans.com/category/jswz/34/1756030.html style=会在带有开关的组件内触发"/>

调度不会在带有开关的组件内触发

我在我的应用程序组件上有此]

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}从'....

回答如下:

更多推荐

调度不会在带有开关的组件内触发

本文发布于:2024-05-07 10:35:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1755854.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   组件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!