Skip to content

Commit 1cf9e18

Browse files
author
Gabe Scholz
committed
Add note to README
1 parent 3073fe6 commit 1cf9e18

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ react_component('HelloMessage', {name: 'John'}, {id: 'hello', class: 'foo', tag:
109109
# <span class="foo" id="hello" data-...></span>
110110
```
111111

112+
### Controller helper
113+
114+
There is also a controller helper `render_react_component` which is included so that you can specify a component as your view instead of an extra view file that only uses the `react_component` view helper.
115+
116+
```ruby
117+
class TodoController < ApplicationController
118+
def show
119+
todos = Todos.all
120+
render_react_component 'TodoList', { todos: todos }, prerender: true
121+
end
122+
```
123+
112124
#### With JSON and Jbuilder
113125

114126
You can pass prepared JSON directly to the helper, as well.

0 commit comments

Comments
 (0)