@Documented
@Target(value=METHOD)
public @interface Callback
JsFunction
then the code gives the callback a user friendly name for debugging. The
code for specifying the friendly name will be optimized away when
ReactConfig.enableComponentNames() returns false. Using JsFunction
also reduces the generated code size.
Using this annotation and the corresponding helper method is entirely optional but does provide some value when building components that you want to easily interact with from the React DevTools or building a component that compares props values to determine whether it needs to re-render.
The method that is annotated with this annotation must also comply with the following constraints:
ReactComponent
Modifier and Type | Optional Element and Description |
---|---|
Feature |
initCallbackContext
The flag indicates whether the annotation processor should manage the calling context.
|
java.lang.String |
name
Return the name of the callback.
|
java.lang.Class |
value
The type of the callback.
|
@Nonnull public abstract java.lang.String name
public abstract java.lang.Class value
JsFunction
to ensure that the method can be
given a useful debug name.public abstract Feature initCallbackContext
Feature.ENABLE
then caller context will be setup. In practical terms
this means that subclasses of ReactArezComponent
will have the callback
annotated with an arez.annotations.Action
annotation. if set to Feature.DISABLE
then the code that invokes the callback is responsible for setting up the calling context. This is
typically used when you are passing a "render" prop into a component that invokes the callback to
render react4j.ReactNode. The Feature.AUTODETECT
value will detect whether the component needs
calling context setup and do so if necessary. At the moment this means that subclasses of
ReactArezComponent
are enabled.