“Uncaught TypeError: React.createClass is not a function” in Render.js file (electron app)

后端 未结 3 1812
再見小時候
再見小時候 2021-02-10 16:47

I\'m new to react.js and I am trying to get this code to replace one line in an html file inside an electron app with whatever is in return inside the MainInterface variable

相关标签:
3条回答
  • 2021-02-10 16:52

    export default class App extends React.Component{
        render() {
            return(
               <h1>its works</h1>
            );
        }
    };

    this works for me, checkout this ReactJs CreateClass is not a function thus its by exports React.component instead of using React.createClass

    0 讨论(0)
  • 2021-02-10 16:56

    React removed createClass from version 16. You can use create-react-class to migrate easily as shown in react documentation.

    // Before (15.4 and below)
    var React = require('react');
    
    var Component = React.createClass({
      mixins: [MixinA],
      render() {
        return <Child />;
      }
    });
    
    // After (15.5)
    var React = require('react');
    var createReactClass = require('create-react-class');
    
    var Component = createReactClass({
      mixins: [MixinA],
      render() {
        return <Child />;
      }
    });
    

    read more about this https://reactjs.org/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactcreateclass

    0 讨论(0)
  • 2021-02-10 17:02

    In the latest version of React, you will notice that React.createClass was removed from the library. One of the biggest changes is that you can create React components using JavaScript classes.

    0 讨论(0)
提交回复
热议问题