Skip to content

Commit e99bee5

Browse files
committed
Merge pull request #50 from meleyal/patch-3
use ruby 1.9 hash syntax in examples
2 parents b6d3294 + 126e2e9 commit e99bee5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Component = React.createClass
6969

7070
```erb
7171
<!-- react_ujs will execute `React.renderComponent(HelloMessage({name:"Bob"}), element)` -->
72-
<div data-react-class="HelloMessage" data-react-props="<%= {:name => 'Bob'}.to_json %>" />
72+
<div data-react-class="HelloMessage" data-react-props="<%= {name: 'Bob'}.to_json %>" />
7373
```
7474

7575
`react_ujs` will also scan DOM elements and call `React.unmountComponentAtNode` on page unload. If you want to disable this behavior, remove `data-react-class` attribute in `componentDidMount`.
@@ -89,17 +89,17 @@ To use `react_ujs`, simply `require` it after `react` (and after `turbolinks` if
8989
There is a view helper method `react_component`. It is designed to work with `react_ujs` and takes a React class name, properties, and HTML options as arguments:
9090

9191
```ruby
92-
react_component('HelloMessage', :name => 'John')
92+
react_component('HelloMessage', name: 'John')
9393
# <div data-react-class="HelloMessage" data-react-props="{&quot;name&quot;:&quot;John&quot;}"></div>
9494
```
9595

9696
By default, a `<div>` element is used. Other tag and HTML attributes can be specified:
9797

9898
```ruby
99-
react_component('HelloMessage', {:name => 'John'}, :span)
99+
react_component('HelloMessage', {name: 'John'}, :span)
100100
# <span data-...></span>
101101

102-
react_component('HelloMessage', {:name => 'John'}, {:id => 'hello', :class => 'foo', :tag => :span})
102+
react_component('HelloMessage', {name: 'John'}, {id: 'hello', class: 'foo', tag: :span})
103103
# <span class="foo" id="hello" data-...></span>
104104
```
105105

@@ -139,10 +139,10 @@ window.Component = Component
139139

140140
#### View Helper
141141

142-
To take advantage of server rendering, use the same view helper `react_component`, and pass in `:prerender => true` in the `options` hash.
142+
To take advantage of server rendering, use the same view helper `react_component`, and pass in `prerender: true` in the `options` hash.
143143

144144
```erb
145-
react_component('HelloMessage', {:name => 'John'}, {:prerender => true})
145+
react_component('HelloMessage', {name: 'John'}, {prerender: true})
146146
```
147147
This will return the fully rendered component markup, and as long as you have included the `react_ujs` script in your page, then the component will also be instantiated and mounted on the client.
148148

0 commit comments

Comments
 (0)