javascript - Set inital state of react component with ajax -


i trying enhance projekt few react components. have managed build app , want.

now need rid of dummy array contains data , fill real data form database.

usually i'd ajax , parse out.

i have checked facebook documentation , i've found following code snippet :

...     componentdidmount: function() {         $.get(this.props.source, function(result) {           var lastgist = result[0];           if (this.ismounted()) {             this.setstate({               username: lastgist.owner.login,               lastgisturl: lastgist.html_url             });           }         }.bind(this));       }, ... 

now question is, how , when should function called in react component. or saved name , gets called automatically?

thank :)

is saved name , gets called automatically?

yes.

https://facebook.github.io/react/docs/component-specs.html#mounting-componentdidmount


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -