Want to dynamically insert script tag that will execute via Reactjs? If your component is dynamic and receive regulary new props, you should also consider other methods (like componentDidUpdate).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | componentDidMount: function(){ var embedCode = this.props.embedCode; $('#scriptContainer').append(embedCode); }, render: function () { return ( <Modal {...this.props} title="Embed on your own site!"> <div className="modal-body"> <div className="tm-embed-container" id="scriptContainer"> </div> <textarea className="tm-embed-code" rows="4" wrap="on" defaultValue={this.props.embedCode}></textarea> </div> </Modal> ); } }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.