Is there a right way to pass data into a React component from the HTML page?

前端 未结 4 399
悲&欢浪女
悲&欢浪女 2021-01-31 08:29

I have a React app like this.

var X = React.createClass({
  componentDidMount: function() {
    fetch(this.props.feed).then(...);
  }
  render: function() {
             


        
4条回答
  •  抹茶落季
    2021-01-31 09:01

    I had a similar problem, dynamically generated pages that contain data relevant to the React stuff.

    I just declared them in the global scope ..

    
    

    .. THEN ..

    ReactDOM.render(
      ,
      document.getElementById('app')
    )
    

    Obviously, from a namespacing perspective, this can have some drawbacks :)

提交回复
热议问题