ReactJS this.state null

前端 未结 5 1227
谎友^
谎友^ 2020-12-28 11:31

Let me preface this by saying I am a novice to ReactJS. I am trying to learn by making a simple site that populates data using React. I have a JSON file that contains link d

5条回答
  •  不思量自难忘°
    2020-12-28 12:11

    Using ES6, the initial state must be created in your constructor for the React component class, like this:

    constructor(props) {
        super(props)
        this.state ={
        // Set your state here
        }
    }
    

    See this documentation.

提交回复
热议问题