phoenix_reactor v0.1.0 PhoenixReactor
Module contains a function which helps to render react component.
Summary
Functions
Renders react component container. It can be called in a phoenix template or directly in a phoenix view
Functions
Renders react component container. It can be called in a phoenix template or directly in a phoenix view.
Using in a template filex
...
<div>
<%= PhoenixReactor.react_container("home", %{message: @message}) %>
<div>
...
Using in a view file
def render("show.html", assigns) do
PhoenixReactor.react_container("home", assigns[:props])
end
Examples:
iex> PhoenixReactor.react_container("home") |> Phoenix.HTML.safe_to_string()
"<div data-react-component=\"home\" data-react-props=\"{}\"></div>"
iex> PhoenixReactor.react_container("home", %{your_message: "Hello World"}) |> Phoenix.HTML.safe_to_string()
"<div data-react-component=\"home\" data-react-props=\"{"yourMessage":"Hello World"}\"></div>"
iex> PhoenixReactor.react_container("home", %{your_message: "Hello World"}, class: "container", id: "home") |> Phoenix.HTML.safe_to_string()
"<div class=\"container\" data-react-component=\"home\" data-react-props=\"{"yourMessage":"Hello World"}\" id=\"home\"></div>"