ReactRender v2.0.1 ReactRender View Source

React Renderer

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Given the component_path and props, returns html

Same as get_html/2 but wraps html in a div which is used to hydrate react component on client side

Starts the ReactRender and workers

Stops the ReactRender and underlying node react render service

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function get_html(component_path, props \\ %{}) View Source
get_html(binary(), map()) :: {:ok, binary()} | {:error, map()}

Given the component_path and props, returns html.

component_path is the path to your react component module relative to the render service.

props is a map of props given to the component. Must be able to turn into json

Link to this function render(component_path, props \\ %{}) View Source
render(binary(), map()) :: {:safe, binary()}

Same as get_html/2 but wraps html in a div which is used to hydrate react component on client side.

This is the preferred function when using with Phoenix

component_path is the path to your react component module relative to the render service.

props is a map of props given to the component. Must be able to turn into json

Link to this function start_link(args) View Source
start_link(keyword()) :: {:ok, pid()} | {:error, any()}

Starts the ReactRender and workers.

Options

  • :render_service_path - (required) is the path to the react render service relative to your current working directory
  • :pool_size - (optional) the number of workers. Defaults to 4

Stops the ReactRender and underlying node react render service