1

In both files, I use

import React from 'react'

and I work with the same workspace and the same syntax, I didn't find any problems to deal with.

I think this difference has something to do with the specific files (vanilla JS and React) or Giving these things a little more formality

3
  • Did you read e.g. stackoverflow.com/q/46169472/3001761? Commented Aug 29, 2023 at 19:05
  • From w3 schools: JSX stands for JavaScript XML. JSX allows us to write HTML elements in JavaScript and place them in the DOM without any createElement() and/or appendChild() methods. JSX converts HTML tags into react elements. Commented Aug 29, 2023 at 19:09
  • Someone asked this question before. Check out this thread. Commented Aug 29, 2023 at 19:16

2 Answers 2

1

In a React project, the main difference between JSX and JS files lies in how they define and structure components.

JSX files contain a mixture of JavaScript code and XML-like syntax to define the structure and appearance of React components. On the other hand, JS files typically hold JavaScript code that can include logic, functions, and imports.

Sign up to request clarification or add additional context in comments.

Comments

1

The difference between ".js" and ".jsx" in a React project is mainly a matter of convention. Both can contain JavaScript and JSX code. Using .jsx makes it clearer that the file contains JSX code, and may help with syntax highlighting and code formatting in some editors. However, using .js is simpler and more common, and does not require any special configuration.

In my organisation, the ES-Lint is configured in such a way that it throws errors if we use .js instead of .jsx for components.

It ultimately comes down to your team's preference and conventions followed.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.