componentWillMount method

  1. @mustCallSuper
  2. @override
void componentWillMount()
inherited

ReactJS lifecycle method that is invoked once, both on the client and server, immediately before the initial rendering occurs.

If you call setState within this method, render will see the updated state and will be executed only once despite the state value change.

See: reactjs.org/docs/react-component.html#mounting-componentwillmount

Implementation

@mustCallSuper
@override
void componentWillMount() {
  // Subscribe to all applicable stores.
  // Stores returned by `redrawOn()` will have their triggers mapped directly
  // to `handleRedrawOn`, which invokes this component's redraw function.
  // Stores included in the `getStoreHandlers()` result will be listened to
  // and wired up to their respective handlers.
  final customStoreHandlers = getStoreHandlers();
  final storesWithoutCustomHandlers =
      redrawOn().where((store) => !customStoreHandlers.containsKey(store));

  customStoreHandlers.forEach(listenToStream);
  storesWithoutCustomHandlers.forEach(listenToStoreForRedraw);
}