Package io.micronaut.views.react
Class ReactViewsRenderer<PROPS>
java.lang.Object
io.micronaut.views.react.ReactViewsRenderer<PROPS>
- Type Parameters:
PROPS
- An introspectable bean type that will be fed to the ReactJS root component as props.
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,ViewsRenderer<PROPS,
io.micronaut.http.HttpRequest<?>>
@Singleton
public class ReactViewsRenderer<PROPS>
extends Object
implements ViewsRenderer<PROPS,io.micronaut.http.HttpRequest<?>>
Instantiates GraalJS and uses it to render React components server side. See the user guide to learn more about how to render React/Preact apps server side.
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
@NonNull io.micronaut.core.io.Writable
Given a <ViewName/> and optionally an object that represents some props (can be a map or introspectable object), returns hydratable HTML that can be booted on the client using the React libraries.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Constructor Details
-
ReactViewsRenderer
@Inject public ReactViewsRenderer()Construct this renderer. Don't call it yourself, as Micronaut Views will set it up for you.
-
-
Method Details
-
render
@NonNull public @NonNull io.micronaut.core.io.Writable render(@NonNull @NonNull String viewName, @Nullable PROPS props, @Nullable @Nullable io.micronaut.http.HttpRequest<?> request) Given a <ViewName/> and optionally an object that represents some props (can be a map or introspectable object), returns hydratable HTML that can be booted on the client using the React libraries.- Specified by:
render
in interfaceViewsRenderer<PROPS,
io.micronaut.http.HttpRequest<?>> - Parameters:
viewName
- The function or class name of the React component to use as the root. It should return an html root tag.props
- If non-null, will be exposed to the given component as React props.request
- The HTTP request object.- Returns:
- A writable where the view will be written to.
-
exists
- Specified by:
exists
in interfaceViewsRenderer<PROPS,
io.micronaut.http.HttpRequest<?>> - Parameters:
viewName
- view name to be rendered- Returns:
- true if a template can be found for the supplied view name.
-