JSX not allowed in files with extension ' .js' with eslint-config-airbnb

后端 未结 6 903
执笔经年
执笔经年 2020-12-04 12:08

I\'ve installed eslint-config-airbnb that is supposed to pre configure ESLINT for React:

Our default export contains all of our ESLint rules, includin

6条回答
  •  伪装坚强ぢ
    2020-12-04 12:29

    Following React documentation:

    Each JSX element is just syntactic sugar for calling React.createElement(component, props, ...children).

    Following Airbnb's style guide:

    Do not use React.createElement unless you’re initializing the app from a file that is not JSX.

    You could do this:

        //index.js
        const app = React.createElement(App);
        ReactDOM.render(app, document.getElementById('root'));
    

提交回复
热议问题