Skip to content

Commit

Permalink
Merge pull request #1093 from wasabigeek/doc/customize-templates
Browse files Browse the repository at this point in the history
Add instructions on overriding component templates
  • Loading branch information
justin808 committed Aug 15, 2022
2 parents ca0de1d + 1eb8ce2 commit d1398ef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Note: Your component is added to `app/javascript/components/` by default.

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

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

### Changing Component Templates

To make simple changes to Component templates, copy the respective template file to your Rails project at `lib/templates/react/component/template_filename`.

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.

## Upgrading

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

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

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

## Related Projects

Expand Down

0 comments on commit d1398ef

Please sign in to comment.