Skip to content

Commit 06286e3

Browse files
author
Gabe Scholz
committed
Add documentation for component rendering
1 parent 4aba49a commit 06286e3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,21 @@ end
203203
- On MRI, you'll get a deadlock with `pool_size` > 1
204204
- If you're using JRuby, you can increase `pool_size` to have real multi-threaded rendering.
205205

206+
### Rendering components instead of views
207+
208+
Beginning in `~> 1.3.0` components can be rendered directly from a controller action with the custom `component` renderer. For example:
209+
210+
```ruby
211+
class TodoController < ApplicationController
212+
def index
213+
@todos = Todo.all
214+
render component: 'TodoList', props: { todos: @todos }
215+
end
216+
end
217+
```
218+
219+
The component will be rendered in place of `yield`.
220+
206221
### Component generator
207222

208223
`react-rails` ships with a Rails generator to help you get started with a simple component scaffold.

0 commit comments

Comments
 (0)