phoenix_reactor v0.0.3 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")
{:safe, ["<div data-react-component=\"home\" data-react-props=\"{}\">", "", "</div>"]}
iex> PhoenixReactor.react_container("home", %{your_message: "Hello World"})
{:safe,
["<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")
{:safe,
["<div class=\"container\" data-react-component=\"home\" data-react-props=\"{"yourMessage":"Hello World"}\" id=\"home\">",
"",
"</div>"]}