@@ -46,11 +46,11 @@ $ rails generate react:install
4646
4747This 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")
7878ReactRailsUJS .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