I'm rendering a react component that needs data that returns asynchronously. How should I pass this to the react component when it returns from the callback?
currently in render function:
var dataToReturn;
asynchCall(args, function(err, results) {
dataToReturn = results;
})
return (
<MyComponent data={dataToReturn} />
)
This of course is not working out because the data has not returned yet. If I move the render into the callback, that seems like a bad programming pattern. Is there anything in the React API meant for this use case?
thank you!