Skip to content

Commit cf355d0

Browse files
authored
Merge pull request #706 from rystraum/patch-1
Updated README.md to include capitalization gotchas
2 parents 81f6480 + 489f54e commit cf355d0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ $ rails generate react:install
4646

4747
This gives you:
4848

49-
- `components/` directory for your React components
50-
- [`ReactRailsUJS`](#ujs) setup in `packs/application.js`
51-
- `packs/server_rendering.js` for [server-side rendering](#server-side-rendering)
49+
- `app/javascript/components/` directory for your React components
50+
- [`ReactRailsUJS`](#ujs) setup in `app/javascript/packs/application.js`
51+
- `app/javascript/packs/server_rendering.js` for [server-side rendering](#server-side-rendering)
5252

53-
When you add a component to `components/`, you can [render it in a Rails view](#view-helper):
53+
When you add a component to `app/javascript/components/`, you can [render it in a Rails view](#view-helper):
5454

5555
```erb
5656
<%= react_component("HelloWorld", { greeting: "Hello" }) %>
@@ -78,6 +78,16 @@ var ReactRailsUJS = require("react_ujs")
7878
ReactRailsUJS.useContext(myCustomContext)
7979
```
8080

81+
### Gotcha: Capitalization
82+
83+
Component File Name | `react_component` call
84+
-----|-----
85+
`app/javascript/components/samplecomponent.js` | `react_component("samplecomponent")`
86+
`app/javascript/components/sample_component.js` | `react_component("sample_component")`
87+
`app/javascript/components/SampleComponent.js` | `react_component("SampleComponent")`
88+
`app/javascript/components/SampleComponent.js.jsx` | Has to be renamed to SampleComponent.jsx, then use `react_component("SampleComponent")`
89+
90+
8191
## Use with Asset Pipeline
8292

8393
`react-rails` provides React.js & a UJS driver to the Rails asset pipeline. Get started by installing:

0 commit comments

Comments
 (0)