I want to render my component after my ajax request is done.
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 render inside the done method of my ajax request.
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 a way to wait for my ajax request to end before start rendering?
 
     
     
     
    