【问题标题】:Loading bar in react redux not working 100%react redux 中的加载条无法 100% 工作
【发布时间】:2019-11-21 11:20:55
【问题描述】:

enter image description here我在使用 React Redux 加载条时遇到问题。它工作 98.89% 并停在这里。我没有收到任何错误。但它不能 100% 工作并停止。我在这里犯了什么错误?非常感谢你,对不起我的英语能力差

这是我的 Reducer.js

import { loadingBarReducer } from 'react-redux-loading-bar'
export default combineReducers({
  ....
  loadingBar: loadingBarReducer
})

这是我的商店

...
import { loadingBarMiddleware } from 'react-redux-loading-bar'
const epic = createEpicMiddleware(rootEpic)
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

export function configureStore(initializeState: any = {}) {
  return createStore(
    rootReducer,
    initializeState,
    composeEnhancers(applyMiddleware(loadingBarMiddleware(), thunk, epic))
  )
}

这是我的组件

import LoadingBar from 'react-redux-loading-bar'
...

  <div>
     <LoadingBar />
  </div>

【问题讨论】:

  • 信息不够。
  • 我使用库 react-redux-loadingbar 按照指令npmjs.com/package/react-redux-loading-bar
  • @paruchuri-p,不要只说“信息不足”。为了回答这个问题,您还需要知道什么?

标签: reactjs redux


【解决方案1】:

这个库不会像 redux-promise 和 redux-saga 那样自动化 redux-thunk 的事情。要使用 thunk,您必须调用:

dispatch(showLoading())
// do long running stuff
dispatch(hideLoading())

在您的动作创建者中。这就是我让它工作的方式。

https://github.com/mironov/react-redux-loading-bar/issues/34

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-02
    • 2019-11-11
    相关资源
    最近更新 更多