setState method

  1. @override
void setState(
  1. Component2 component,
  2. Map? newState,
  3. SetStateCallback? callback
)
override

Implementation

@override
void setState(Component2 component, Map? newState, SetStateCallback? callback) {
  // Short-circuit to match the ReactJS 16 behavior of not re-rendering the component if newState is null.
  if (newState == null) return;

  final firstArg = jsBackingMapOrJsCopy(newState);

  if (callback == null) {
    component.jsThis.setState(firstArg);
  } else {
    component.jsThis.setState(firstArg, allowInterop(([_]) {
      callback();
    }));
  }
}