Answer the question
In order to leave comments, you need to log in
How can a component get data?
There is a component that is rendered on the server, then on the client side.
The state of the component says:
state = {
globalData: this.props.globalData
}
Answer the question
In order to leave comments, you need to log in
For example, like this:
in the page code, write
<script>
var globalData = '<%=JSON.stringify(this.props.globalData)%>';
</script>
var data = JSON.parse(window.globalData);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question