Regarding the issue you raised about 'React error showing JSX not configured', this error typically occurs when developing React applications with TypeScript. This is because TypeScript requires explicit instructions to parse JSX syntax. The error message typically indicates that the TypeScript configuration file (i.e., tsconfig.json) lacks the correct settings to support JSX.
- Check and update the
tsconfig.jsonfile: Ensure thetsconfig.jsonfile has the following configuration:
json{ "compilerOptions": { "jsx": "react" } }
Here, "jsx": "react" instructs TypeScript to use React's JSX transformation. If using the new JSX transformation in React 17 or higher, set it to "jsx": "react-jsx".
-
Restart the development server: After modifying the configuration, restart your development server (e.g., using
npm startwith Create React App) to apply the changes. -
Check TypeScript version: Ensure the TypeScript version you are using supports your JSX configuration. For example, if you use "jsx": "react-jsx", you need TypeScript 4.1 or higher.
For example, in a previous project, we encountered a similar issue when migrating from Create React App's default settings to a custom Webpack configuration. Initially, we overlooked the jsx configuration in tsconfig.json. After identifying and fixing this, the project compiled correctly, and the error disappeared.