Solvedjavascript .jsx extension cannot be used with React Native

Since .jsx extension cannot be used with React Native (Cf. facebook/react-native#5233), if someone wants to use this config with React Native, the rule react/jsx-filename-extension should be set to .js only instead of .jsx only.

21 Answers

✔️Accepted Answer

@borisyankov "what's common" isn't the primary motivator for this guide, it's "what we use at Airbnb". We believe that .js files should only ever contain actual, standard JavaScript, and JSX is decidedly not that.

Other Answers:

"react/jsx-filename-extension": ["error", { "extensions": [".js", ".jsx"] }]

@julesmoretti

{
    "extends": "airbnb",

+    "rules": {
+      // `.jsx` extension cannot be used with React Native
+      // https://github.com/airbnb/javascript/issues/982
+      "react/jsx-filename-extension": ["error", { "extensions": [".js", ".jsx"] }]
+    }
}

@stonecold123 @youngjuning try this :

module.exports = {
  resolver: {
    sourceExts: ['js', 'json', 'ts', 'tsx', 'jsx']
  }
};

Apart from React Native, it is very common to use .js extensions for files that include JSX.
Having this as a default doesn't make sense.

More Issues: