0

应该是这样的

但是这种类型会进入新的 redux 实例

如果我用超时调用该操作没问题。

  componentDidMount(){
    setTimeout(()=>this.props.isLoggedIn(), 100)
  }

或者如果我在渲染下调用,就没有问题了。

  render() {
    this.props.isLoggedIn()
    ...
    ...

仅当我在应用加载时调用 componentDidUpdate 下的操作时,才会出现此问题。像那样:

  componentDidMount(){
    this.props.isLoggedIn() //problem
  }

导致拆分 redux 实例...

4

1 回答 1

0

好的,我发现了问题。我的错误用法 createStore 函数很有趣。

我在 render() 中调用

  render() {
    const store = createStore(reducers, composeWithDevTools(applyMiddleware(ReduxThunk)))
    ...
    ...

现在我移到顶部,问题解决了。

const store = createStore(reducers, {}, applyMiddleware(ReduxThunk))

export default class App extends React.Component {
  render() {
    return (
      <Provider store={store}>
        ...
        ...
于 2019-11-17T14:08:34.730 回答