Skip to content

Commit d1398ef

Browse files
authored
Merge pull request #1093 from wasabigeek/doc/customize-templates
Add instructions on overriding component templates
2 parents ca0de1d + 1eb8ce2 commit d1398ef

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
@@ -110,7 +110,7 @@ Note: Your component is added to `app/javascript/components/` by default.
110110

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

113-
Example:
113+
Example:
114114
```
115115
<%= react_component("my_subdirectory/HelloWorld", { greeting: "Hello from react-rails." }) %>
116116
```
@@ -624,6 +624,12 @@ You can also specify this option in `react_component`:
624624
<%= react_component('HelloMessage', {name: 'John'}, {camelize_props: true}) %>
625625
```
626626

627+
### Changing Component Templates
628+
629+
To make simple changes to Component templates, copy the respective template file to your Rails project at `lib/templates/react/component/template_filename`.
630+
631+
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.
632+
627633
## Upgrading
628634

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

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

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

693699
## Related Projects
694700

0 commit comments

Comments
 (0)