public abstract class Component
extends java.lang.Object
Constructor and Description |
---|
Component() |
Modifier and Type | Method and Description |
---|---|
void |
bindComponent(NativeComponent nativeComponent) |
protected void |
componentDidCatch(elemental2.core.JsError error,
ReactErrorInfo info)
The componentDidCatch() method works like a JavaScript catch {} block, but for components.
|
void |
performPostConstruct()
Wrapper method that delegates to the
postConstruct() method. |
ReactNode |
performRender() |
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 void |
scheduleRender(boolean force)
Schedule this component for re-rendering.
|
protected void |
storeDebugDataAsState()
Store debug data on the state object of the native component.
|
protected void |
validatePropValues(jsinterop.base.JsPropertyMap<java.lang.Object> props)
Perform validation on props supplied to the component.
|
public final void bindComponent(@Nonnull NativeComponent nativeComponent)
protected final jsinterop.base.JsPropertyMap<java.lang.Object> props()
protected final void scheduleRender(boolean force)
shouldComponentUpdate()
lifecycle method will be skipped if the force parameter is true as calling this method is equivalent to
calling forceUpdate() on the native react component. See the React Component
documentation for more details.force
- if true then the component will skip the shouldComponentUpdate()
lifecycle method.@Nullable protected abstract ReactNode render()
@Nullable public final ReactNode performRender()
public 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 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 void validatePropValues(@Nonnull jsinterop.base.JsPropertyMap<java.lang.Object> props)
props
- the props of the component.protected final void storeDebugDataAsState()
React.shouldStoreDebugDataAsState()
returns true and is primarily
done to make it easy to debug the component from within React DevTools.protected void populateDebugData(@Nonnull jsinterop.base.JsPropertyMap<java.lang.Object> state)
state
- the property map to populate with debug data.