LoginSignup
5
2

More than 5 years have passed since last update.

react-native + redux で hot reloading でのエラー対応

Posted at

ベタに書くと、 Redux 2.x からは Hot Reloading に失敗してエラーが出る。

const store = createStore(reducers);

class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <View>
          <Router />
        </View>
      </Provider>
    );
  }
}

export default App;

スクリーンショット 2017-03-08 14.08.42.png

対応法

store の動的差し替え出来るようなコードにする。

function configureStore() {
  return createStore(reducers);
}

class App extends Component {
  state = {
    store: configureStore(),
  };
  render() {
    return (
      <Provider store={this.state.store}>
        <View>
          <Router />
        </View>
      </Provider>
    );
  }
}

export default App;

It works!

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2