Permalink
Browse files

Update README; use Jason instead of Poison

  • Loading branch information...
geolessel committed Jan 3, 2019
1 parent f31f836 commit fba651215baf1242a8e1e87b7756289a88f00817
Showing with 17 additions and 7 deletions.
  1. +13 −3 README.md
  2. +2 −2 lib/react_phoenix/client_side.ex
  3. +2 −2 mix.exs
@@ -81,7 +81,17 @@ Since we want React and would like to write JSX in our app, we need
to make sure we get the packages brunch needs in order to compile our files.

```
npm install react react-dom babel-preset-env babel-preset-react --save
# using npm
> npm install react react-dom --save
> npm @babel/preset-env @babel/preset-react --save-dev
```

or

```
# using yarn
> yarn add react react-dom
> yarn add --dev @babel/preset-env @babel/preset-react
```

We also need to activate those presets from the `assets/.babelrc` file:
@@ -90,8 +100,8 @@ We also need to activate those presets from the `assets/.babelrc` file:
// Configure your plugins
{
"presets": [
"env",
"react" // <-- ADD THIS!
"@babel/preset-env",
"@babel/preset-react" // <-- ADD THIS!
]
}
```
@@ -50,7 +50,7 @@ defmodule ReactPhoenix.ClientSide do
end

def react_component(name, props) when is_map(props) do
props = Poison.encode!(props)
props = Jason.encode!(props)
content_tag(:div, "", [{:data, [react_class: name, react_props: props]}])
end

@@ -80,7 +80,7 @@ defmodule ReactPhoenix.ClientSide do
@spec react_component(name :: String.t(), props :: map, opts :: [target_id: String.t()]) ::
Phoenix.HTML.safe()
def react_component(name, props, opts) when is_map(props) do
props = Poison.encode!(props)
props = Jason.encode!(props)

content_tag(:div, "", [
{:data, [react_class: name, react_props: props, react_target_id: opts[:target_id]]}
@@ -19,7 +19,7 @@ defmodule ReactPhoenix.Mixfile do
end

def application do
[extra_applications: [:logger, :phoenix_html, :poison]]
[extra_applications: [:logger, :phoenix_html, :jason]]
end

def description do
@@ -34,7 +34,7 @@ defmodule ReactPhoenix.Mixfile do
{:ex_doc, ">= 0.0.0", only: :dev},
{:dialyxir, ">= 0.5.0", only: :dev},
{:phoenix_html, "~> 2.11"},
{:poison, "~> 4.0"}
{:jason, "~> 1.1"}
]
end

0 comments on commit fba6512

Please sign in to comment.