Skip to content

Commit 1eb8ce2

Browse files
committed
📝 Add instructions on overriding component templates
1 parent f8148d5 commit 1eb8ce2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Note: Your component is added to `app/javascript/components/` by default.
116116

117117
Note: If your component is in a subdirectory you will append the directory path to your erb component call.
118118

119-
Example:
119+
Example:
120120
```
121121
<%= react_component("my_subdirectory/HelloWorld", { greeting: "Hello from react-rails." }) %>
122122
```
@@ -630,6 +630,12 @@ You can also specify this option in `react_component`:
630630
<%= react_component('HelloMessage', {name: 'John'}, {camelize_props: true}) %>
631631
```
632632

633+
### Changing Component Templates
634+
635+
To make simple changes to Component templates, copy the respective template file to your Rails project at `lib/templates/react/component/template_filename`.
636+
637+
For example, to change the [ES6 Component template](https://github.com/reactjs/react-rails/blob/master/lib/generators/templates/component.es6.jsx), copy it to `lib/templates/react/component/component.es6.jsx` and modify it.
638+
633639
## Upgrading
634640

635641
### 2.3 to 2.4
@@ -694,7 +700,7 @@ Hot Module Replacement is [possible with this gem](https://stackoverflow.com/a/5
694700

695701
Sample repo that shows HMR working with `react-rails`: [https://github.com/edelgado/react-rails-hmr](https://github.com/edelgado/react-rails-hmr)
696702

697-
One caveat is that currently you [cannot Server-Side Render along with HMR](https://github.com/reactjs/react-rails/issues/925#issuecomment-415469572).
703+
One caveat is that currently you [cannot Server-Side Render along with HMR](https://github.com/reactjs/react-rails/issues/925#issuecomment-415469572).
698704

699705
## Related Projects
700706

0 commit comments

Comments
 (0)