Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


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?

1 Answer

18,813 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.

Ty!! ^^