React, component life cycle, how to load virtual dom first?

problem description

in html, you use a property that state does not define, but if you use the componentWillMount () method to define this property, the result will be an error. The browser prompts that the property is not defined and cannot refer to
Cannot read property"0" of undefined

.

the environmental background of the problems and what methods you have tried

you can only define it

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

this.state = {

        // menu:[{name:""}]
      }

what result do you expect? What is the error message actually seen?

speechless, didn"t you say that render is behind componentWillMount


state,props-> componentWillMount-> render-> componentDidMount this is the mount phase

Virtual DOM is performed in render

I don't know exactly what the main questions are
comment answers

I hope I can help you!

What is the relationship between

and JAVA? take a look at the tag


state attribute read-only attribute. Do not write
define the
setting using this.state = {} in the constructor. Use this.setState ({key:value}) to set
if you do not define it, you will report an error if you directly set the value, because when you call setState, the value in state will be traversed and assigned.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31b37-2bdcd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31b37-2bdcd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?