Tutorial by Examples

Sometimes a component needs to render some data from a remote endpoint (e.g. a REST API). A standard practice is to make such calls in componentDidMount method. Here is an example, using superagent as AJAX helper: import React from 'react' import request from 'superagent' class App extends Rea...
The following would work in IE9+ import React from 'react' class App extends React.Component { constructor () { super() this.state = {someData: null} } componentDidMount () { var request = new XMLHttpRequest(); request.open('GET', '/my/url', true); request...
The following example shows how a set of data obtained from a remote source can be rendered into a component. We make an AJAX request using fetch, which is build into most browsers. Use a fetch polyfill in production to support older browsers. You can also use any other library for making requests ...

Page 1 of 1