TypedSnapshot<TSnapshot> mixin

Mixin that enforces consistent typing of the snapshot parameter returned by Component2.getSnapshotBeforeUpdate and passed into Component2.componentDidUpdate.

EXAMPLE:

class _ParentComponent extends react.Component2
    with react.TypedSnapshot<bool> {

  // Note that the return value is specified as an bool, matching the mixin
  // type.
  bool getShapshotBeforeUpdate(prevProps, prevState) {
    if (prevProps["foo"]) {
      return true;
    }
    return null;
  }

  // Note that the snapshot parameter is consistently typed with the return
  // value of getSnapshotBeforeUpdate.
  void componentDidUpdate(prevProps, prevState, [bool snapshot]) {
    if (snapshot == true) {
      // Do something
    }
  }

  /* Include other standard component logic */

}

This mixin should only be used with Component2 or UiComponent2. This is not enforced via the on keyword because of an issue with the Dart SDK.

See: github.com/dart-lang/sdk/issues/38098

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

componentDidUpdate(Map prevProps, Map prevState, [covariant TSnapshot snapshot]) → void
getSnapshotBeforeUpdate(Map prevProps, Map prevState) → TSnapshot
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited