React.js: Is it possible to convert a react component to HTML DOM's?

后端 未结 5 495
孤城傲影
孤城傲影 2021-02-05 05:14

I\'m working on a map-based app that uses Google Map API to create markers and its info window in React.js. The infowindow.setContent() only accepts either a

5条回答
  •  遥遥无期
    2021-02-05 06:01

    You could also use React's renderToString() method

    _renderInfoWindow: function(place) {
      return React.renderToString(
        

    {place.name}

    {place.cost}

    ); }

    This should work for a simple component as shown. React.renderToString() will return only the html for the component.

提交回复
热议问题