Why do we use extension .js instead of .jsx?
I took a very beginner React course on youtube before the Treehouse course and they saved all the components as .jsx. Is there a difference between saving it as jsx instead of js?
rydavimTreehouse Moderator 16,153 Points
I'm not very familiar with React specifically, but as a general short answer - there is no real difference when it comes to the file extensions in this case. Whatever bundler or compiler or such that you're using should resolve the type of file contents for you.
However, there may be some best-practices to consider. Having not gone through whatever course you're working on I can't say for sure, but it is my opinion that it's usually a good idea for non-vanilla code to use their applicable extensions. So I would personally use
.jsx in this case, but practically it shouldn't really effect anything.
Edit: I'm not sure if it's related to your question, but here's a brief article about using React Without JSX.