Reputation: 57
I have the following resources:
test.js
var gblData;
function getData(){
//webservice to set value to gblData
}
React jsx file
//use the gblData to render the html page
html file
I tried the following ways to call the getData() before the jsx file so that gblData is not undefined. But it is failed.
1 html body onload function
2 jquery document ready
Upvotes: 2
Views: 3507
Reputation: 683
Is your React.renderComponent
call after everything else? Try the following.
You can have your jsx file declare all your components, but you can render them from another file.
var glbData;
function getData(){
...
...
React.renderComponent(<YourComponent/>, document.body);
}
Here's a fiddle.
Upvotes: 1