setState method

void setState(
  1. dynamic newState, [
  2. dynamic callback()?
])

Update the Dart component's state to the provided newState value and force a re-render.

Optionally accepts a callback that gets called after the component updates.

Also allows newState to be used as a transactional setState callback.

See: facebook.github.io/react/docs/react-component.html#setstate

If you are rendering a function or DOM component using mount, calling setState will throw a StateError.

See getInstance for more information about this limitation.

Implementation

void setState(newState, [callback()?]) {
  if (!_isCompositeComponent) {
    throw StateError(
        'setState() is only supported when the rendered object is a composite (class based) component.');
  }

  getDartInstance()!.setState(newState, callback);
}