5 ms·
"Recommend using .jsx extension for React components, rather than .js" I like .js over .jsx because I can require/import without explicit extension. import
by liviu 11y ago
"Recommend using .jsx extension for React components, rather than .js"
I like .js over .jsx because I can require/import without explicit extension.
import Foo from './Foo';
vs
import Foo from './Foo.jsx';
- Rygu 11y agoIf you're using webpack (who isn't?) then you can add .jsx to the known and attempted extensions. Although I prefer .js as well because there's eventually there's no reason to structure your JS codebase on extension-level. Better do it at the directory-level.
- fit2rule 11y agoGreat, so you'll never be quite sure whether that module is a plain ol' javascript, or contains React-extended components... eventually it'll all blend together and you won't have much awareness, say .. a year or so after you've put the code to bed .. what is where and how ..
- liviu 11y agoNot really. In a real-case scenario React-extended components stays in "components" directory and is not to hard to be aware that is react-extended component. But yes, I got your point.