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

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -