reactjsreact-nativereact-reduxredux-thunkreact-native-debugger

Why redux multiple initializing


Must be like that

But this type going to new redux instance

No problem if I call the action with timeout.

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

Or if I call under render, no problem again.

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

This problem occurs only when i call the action under componentDidUpdate on app load. Like that:

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

Causing the split redux instance...


Solution

  • Ok, i found the problem. Interesting with my wrong usage createStore function.

    I was calling in render()

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

    Now i move to out of the top, problem solved.

    const store = createStore(reducers, {}, applyMiddleware(ReduxThunk))
    
    export default class App extends React.Component {
      render() {
        return (
          <Provider store={store}>
            ...
            ...