I want to make my component after executing my ajax request.
Below you can see my code
var CategoriesSetup = React.createClass({ render: function(){ var rows = []; $.get('http://foobar.io/api/v1/listings/categories/').done(function (data) { $.each(data, function(index, element){ rows.push(<OptionRow obj={element} />); }); return (<Input type='select'>{rows}</Input>) }) } });
But I get the error below because I am returning the visualization inside the made ajax request method.
Uncaught Error: Invariant Violation: CategoriesSetup.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object.
Is there any way to wait for my ajax request to complete before rendering starts?
javascript ajax asynchronous reactjs jquery-deferred
tunaktunak Nov 28 '14 at 16:20 2014-11-28 16:20
source share