I'm just getting started with React
in Rails
.
When I come across other's Rails
apps with React
, I find some of them add a leading underscore when naming *.js.*
files in /app/assets/javascripts/components/
.
e.g. Sample React Rails App
Component files are like:
_comment.js.jsx
While some don't, e.g. Account React Rails App
Component files are like:
record.js.coffee
So what difference does it make to add the leading underscore?
I know in Rails
view, naming a *.html.erb
file with leading underscore means it's a partial which you can reuse and we call render
method to render it. But here the *.js.*
files are require by components.js
with //= require_tree ./components
. So even you remove the underscore, it makes no difference. And I believe this is the only part which "reuse" the component.