public abstract class Component
extends java.lang.Object
Constructor and Description |
---|
Component() |
Modifier and Type | Method and Description |
---|---|
protected void |
componentDidCatch(elemental2.core.JsError error,
ReactErrorInfo info)
The componentDidCatch() method works like a JavaScript catch {} block, but for components.
|
protected void |
componentDidMount()
This method is invoked after a component is attached to the DOM.
|
protected void |
componentDidUpdate()
This method is invoked immediately after updating occurs.
|
protected void |
componentWillUnmount()
This method is invoked immediately before a component is unmounted and destroyed.
|
protected java.lang.String |
getKey()
Return the key associated with the component if any.
|
protected void |
performComponentWillUnmount()
Wrapper method that delegates to the
componentWillUnmount() method. |
protected void |
performPostConstruct()
Wrapper method that delegates to the
postConstruct() method. |
protected ReactNode |
performRender()
Wrapper method that delegates to the
render() method. |
protected void |
populateDebugData(jsinterop.base.JsPropertyMap<java.lang.Object> state)
Populate the state parameter with any data that is useful when debugging the component.
|
protected void |
postConstruct()
This method is invoked after the component is constructed and bound to a native react component.
|
protected jsinterop.base.JsPropertyMap<java.lang.Object> |
props()
Return the component props from the native component.
|
protected abstract ReactNode |
render()
Render the component.
|
protected boolean |
reportPropChanges(jsinterop.base.JsPropertyMap<java.lang.Object> props,
jsinterop.base.JsPropertyMap<java.lang.Object> nextProps,
boolean inComponentDidUpdate)
Detect and report changes in props that are
Prop.observable() . |
protected void |
scheduleRender()
Schedule this component for re-rendering.
|
protected boolean |
shouldReportPropChanges(boolean inComponentDidUpdate)
Helper method invoked by
reportPropChanges(JsPropertyMap, JsPropertyMap, boolean) method
generated by the annotation processor. |
protected boolean |
shouldUpdateOnPropChanges(jsinterop.base.JsPropertyMap<java.lang.Object> nextProps)
Detect changes in props that that do not require specific actions on change.
|
protected jsinterop.base.JsPropertyMap<java.lang.Object> |
state()
Return the component state from the native component.
|
protected void |
validatePropValues(jsinterop.base.JsPropertyMap<java.lang.Object> props)
Perform validation on props supplied to the component.
|
protected final jsinterop.base.JsPropertyMap<java.lang.Object> state()
protected final jsinterop.base.JsPropertyMap<java.lang.Object> props()
@Nullable protected final java.lang.String getKey()
protected final void scheduleRender()
shouldComponentUpdate(JsPropertyMap)
lifecycle method will be skipped. Calling this method is equivalent to calling forceUpdate() on the native
react component. See the React Component
documentation for more details.@Nullable protected abstract ReactNode render()
@Nullable protected ReactNode performRender()
render()
method.
This method exists to give middleware a mechanism to hook into component lifecycle step.protected void performPostConstruct()
postConstruct()
method.
This method exists to give middleware a mechanism to hook into component lifecycle step.protected void postConstruct()
render()
, therefore
setting state in this method will not trigger a re-rendering. This replaces the
componentWillMount
lifecycle method from react as well as the code that appears in constructors in native React ES6
components.protected void componentDidMount()
protected void componentDidUpdate()
protected void componentWillUnmount()
componentDidMount()
See the React Component documentation for more details.protected void performComponentWillUnmount()
componentWillUnmount()
method.
This method exists to give middleware a mechanism to hook into component lifecycle step.protected void componentDidCatch(@Nonnull elemental2.core.JsError error, @Nonnull ReactErrorInfo info)
Note that error boundaries only catch errors in the components below them in the tree. An error boundary can’t catch an error within itself. If an error boundary fails trying to render the error message, the error will propagate to the closest error boundary above it. This, too, is similar to how catch {} block works in JavaScript.
error
- the error that has been thrown.info
- information about component stack during thrown error.protected boolean reportPropChanges(@Nonnull jsinterop.base.JsPropertyMap<java.lang.Object> props, @Nonnull jsinterop.base.JsPropertyMap<java.lang.Object> nextProps, boolean inComponentDidUpdate)
Prop.observable()
.
This method is a template method that may be overridden by subclasses generated
by the annotation processor based on configuration of props.
This method can be invoked from either the shouldComponentUpdate(JsPropertyMap)
method
or the componentDidUpdate()
method. If the method is not invoked from the
shouldComponentUpdate(JsPropertyMap)
method first due to a scheduleRender()
call then the call from componentDidUpdate()
will report any changes to
the observable props otherwise this will only occur in the invocation of the method from the
shouldComponentUpdate(JsPropertyMap)
method. This means that the props
are marked as Prop.observable()
and are used by a @Computed
method from within the render call will only be reported as being changed once, normally before the
render call. Thus the computed will be marked as potentially stale and recomputed if used in the render.
Otherwise the computed will be marked as potentially stale after the render which could potentially
trigger a re-render of the component.
props
- the old properties of the component.nextProps
- the new properties of the component.inComponentDidUpdate
- true if this is being invoked from componentDidUpdate()
, false if this is being invoked from shouldComponentUpdate(JsPropertyMap)
Prop.shouldUpdateOnChange()
and has changed.protected final boolean shouldReportPropChanges(boolean inComponentDidUpdate)
reportPropChanges(JsPropertyMap, JsPropertyMap, boolean)
method
generated by the annotation processor. This will return true if the changes should be reported.inComponentDidUpdate
- true if this is being invoked from componentDidUpdate()
, false if this is being invoked from shouldComponentUpdate(JsPropertyMap)
protected boolean shouldUpdateOnPropChanges(@Nonnull jsinterop.base.JsPropertyMap<java.lang.Object> nextProps)
Prop.shouldUpdateOnChange()
to false. Otherwise this method will return false.nextProps
- the new properties of the component.protected void validatePropValues(@Nonnull jsinterop.base.JsPropertyMap<java.lang.Object> props)
props
- the props of the component.protected void populateDebugData(@Nonnull jsinterop.base.JsPropertyMap<java.lang.Object> state)
state
- the property map to populate with debug data.