Reactjs React redux操作被无休止地调用(无限循环)

Reactjs React redux操作被无休止地调用(无限循环),reactjs,react-redux,react-router,redux-async-actions,Reactjs,React Redux,React Router,Redux Async Actions,当在useEffect函数中调用action时,react组件将无休止地重新渲染 useEffect(() => { props.getApi('pages/websitepage/page_type/choices') },[]) 在这里,我使用connect方法来调度操作(也尝试了hooks方法) 正如您在这里看到的,我正在调用action dispatch来存储状态。但是组件一直在重新渲染,有没有任何可能的解决方案可以让我停止这种行为? 在下面附加记录器响应 act

当在useEffect函数中调用action时,react组件将无休止地重新渲染

  useEffect(() => {
    props.getApi('pages/websitepage/page_type/choices')
  },[])
在这里,我使用connect方法来调度操作(也尝试了hooks方法)

正如您在这里看到的,我正在调用action dispatch来存储状态。但是组件一直在重新渲染,有没有任何可能的解决方案可以让我停止这种行为? 在下面附加记录器响应

action FETCH_RESPONSE
    prev state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
    action     {type: "FETCH_RESPONSE", payload: Array(4)}
    next state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
action FETCH_RESPONSE
    prev state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
    action     {type: "FETCH_RESPONSE", payload: Array(4)}
    next state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
action FETCH_RESPONSE
    prev state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
    action     {type: "FETCH_RESPONSE", payload: Array(4)}
    next state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}

您需要使用redux thunk或redux saga来进行api调用this@SwarupBamexport const store=createStore(authReducers,applyMiddleware(thunk,logger))您可以为此创建stackblitz应用程序吗?在没有看到代码的情况下进行调试是很困难的。
action FETCH_RESPONSE
    prev state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
    action     {type: "FETCH_RESPONSE", payload: Array(4)}
    next state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
action FETCH_RESPONSE
    prev state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
    action     {type: "FETCH_RESPONSE", payload: Array(4)}
    next state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
action FETCH_RESPONSE
    prev state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}
    action     {type: "FETCH_RESPONSE", payload: Array(4)}
    next state {isAuthenticated: true, error: null, isLoading: false, currentBlogPage: 0, submitting: false, …}