Component2 class abstract
Top-level ReactJS Component class which provides the ReactJS Component API.
Differences from the deprecated Component:
-
"JS-backed maps" - uses the JS React component's props / state objects maps under the hood instead of copying them into Dart Maps. Benefits:
- Improved performance
- Props/state key-value pairs are visible to React, and show up in the Dev Tools
- Easier to maintain the JS-Dart interop and add new features
- Easier to interop with JS libraries like react-redux
-
Supports the new lifecycle methods introduced in React 16 (See method doc comments for more info)
-
Drops support for "unsafe" lifecycle methods deprecated in React 16 (See method doc comments for migration instructions)
-
Supports React 16 context
- Implemented types
Constructors
Properties
-
childContextKeys
→ Iterable<
String> -
Do not use.
no setteroverride
- context ↔ dynamic
-
The context value from the contextType assigned to this component.
The value is passed down from the provider of the same contextType.
You can reference context in any of the lifecycle methods including the render function.
getter/setter pairoverride
-
contextKeys
→ Iterable<
String> -
Do not use.
no setteroverride
- contextType → Context?
-
Accessed once and cached when instance is created. The contextType property on a class can be assigned
a ReactContext object created by React.createContext. This lets you consume the nearest current value of
that Context using context.
no setter
- defaultProps → Map
-
Invoked once and cached when registerComponent is called. Values in the mapping will be set on props
if that prop is not specified by the parent component.
no setter
- displayName → String?
-
Allows the ReactJS
displayName
property to be set for debugging purposes.no setteroverride - hashCode → int
-
The hash code for this object.
no setterinherited
- initialState → Map
-
Invoked once before the
Component
is mounted. The return value will be used as the initial value of state.no setter - jsThis ↔ ReactComponent
-
The JavaScript
ReactComponent
instance of thisComponent
returned by render.getter/setter pairoverride-getter - nextContext ↔ Map?
-
Do not use.
getter/setter pairoverride
- nextProps ↔ Map
-
Do not use.
getter/setter pairoverride
- nextState → Map
-
Do not use.
no setteroverride
- prevContext ↔ Map?
-
Do not use.
getter/setter pairoverride
- prevState ↔ Map
-
Do not use.
getter/setter pairoverride
- props ↔ Map
-
ReactJS Component props.
getter/setter pairoverride
-
propTypes
→ Map<
String, PropValidator< Never> > -
Allows usage of PropValidator functions to check the validity of a prop within the props passed to it.
no setter
- ref ↔ RefMethod
-
Do not use.
getter/setter pairoverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
setStateCallbacks
→ List<
SetStateCallback> -
Do not use.
no setteroverride
- state ↔ Map
-
ReactJS Component state.
getter/setter pairoverride
-
transactionalSetStateCallbacks
→ List<
StateUpdaterCallback> -
The List of transactional
setState
callbacks to be called before the component updates.no setteroverride
Methods
-
componentDidCatch(
dynamic error, ReactErrorInfo info) → void -
ReactJS lifecycle method that is invoked after an
error
is thrown by a descendant. -
componentDidMount(
) → void -
ReactJS lifecycle method that is invoked once, only on the client (not on the server), immediately after the
initial rendering occurs.
override
-
componentDidUpdate(
Map prevProps, Map prevState, [dynamic snapshot]) → void -
ReactJS lifecycle method that is invoked immediately after the
Component
's updates are flushed to the DOM.override -
componentWillMount(
) → void -
ReactJS lifecycle method that is invoked once immediately before the initial rendering occurs.
override
-
componentWillReceiveProps(
Map nextProps) → void -
ReactJS lifecycle method that is invoked when a
Component
is receiving new props (nextProps
).override -
componentWillReceivePropsWithContext(
Map newProps, dynamic nextContext) → void -
Do not use; this is part of the legacy context API.
override
-
componentWillUnmount(
) → void -
ReactJS lifecycle method that is invoked immediately before a
Component
is unmounted from the DOM.override -
componentWillUpdate(
Map nextProps, Map nextState) → void -
ReactJS lifecycle method that is invoked when a
Component
is receiving new props (nextProps
) and/or state (nextState
).override -
componentWillUpdateWithContext(
Map nextProps, Map nextState, dynamic nextContext) → void -
Do not use; this is part of the legacy context API.
override
-
forceUpdate(
[SetStateCallback? callback]) → void - Causes render to be called, skipping shouldComponentUpdate.
-
getChildContext(
) → Map< String, dynamic> -
Do not use; this is part of the legacy context API.
override
-
getDefaultProps(
) → Map -
Invoked once and cached when registerComponent is called. Values in the mapping will be set on props
if that prop is not specified by the parent component.
override
-
getDerivedStateFromError(
dynamic error) → Map? -
ReactJS lifecycle method that is invoked after an
error
is thrown by a descendant. -
getDerivedStateFromProps(
Map nextProps, Map prevState) → Map? -
ReactJS lifecycle method that is invoked before rendering when new props (
nextProps
) are received. -
getInitialState(
) → Map -
Invoked once before the
Component
is mounted. The return value will be used as the initial value of state.override -
getSnapshotBeforeUpdate(
Map prevProps, Map prevState) → dynamic - ReactJS lifecycle method that is invoked immediately after re-rendering when new props and/or state values are committed.
-
initComponentInternal(
Map props, void _jsRedraw(), [RefMethod? ref, dynamic _jsThis, Map? context]) → dynamic -
Do not use.
override
-
initStateInternal(
) → dynamic -
Do not use.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
redraw(
[SetStateCallback? callback]) → void -
Deprecated. Will be removed when Component is removed in a future major release.
override
-
render(
) → dynamic -
Examines props and state and returns a ReactNode.
override
-
replaceState(
Map? newState, [SetStateCallback? callback]) → void -
Do not use.
override
-
setState(
covariant Map? newState, [SetStateCallback? callback]) → void -
Triggers a rerender with new state obtained by shallow-merging
newState
into the current state.override -
setStateWithUpdater(
StateUpdaterCallback updater, [SetStateCallback? callback]) → void -
Triggers a rerender with new state obtained by shallow-merging
the return value of
updater
into the current state. -
shouldComponentUpdate(
Map nextProps, Map nextState) → bool -
ReactJS lifecycle method that is invoked before rendering when
nextProps
and/ornextState
are being received.override -
shouldComponentUpdateWithContext(
Map nextProps, Map nextState, dynamic nextContext) → bool -
Do not use; this is part of the legacy context API.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
transferComponentState(
) → void -
Do not use.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited