简体   繁体   中英

Problems with syntax of React.js

please help me in the code. i have a problem with getInitialState() , the code isn't work: enter image description here

the mistake is on the picture, but i can't see this.

You're using ES6 classes, which means you need to use a constructor to initialize the state:

class App extends Component {
    constructor(props) {
        super(props);
        this.state = {
            show: true
        };
    }

    // ..
}

Reference: What is the difference between using constructor vs getInitialState in React / React Native?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM