Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"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';


If 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.


Great, 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 ..


Not 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: