javascript - How to get data from global function -
i'am new in react question easy resolve. made simple version of code illustrate problem.
class reactcomponent extends component { addtoken(token){ this.props.actionaddodtoken(token); } render(){ return ( <div> <h1>this.props.token</h1> </div> ) } } function mapstatetoprops(state){ return {addonedrivetoken: state.addonedrivetoken} } function mapdispatchtoprops(dispatch) { return bindactioncreators({...boundactioncreators}, dispatch); } function sendtocomponent(data) { let data ="some string data"; } export default connect(mapstatetoprops, mapdispatchtoprops)(adddrive);
unfortunately sendto component global function because data child popup.
window.opener.sendtocomponent(data);
sendtocomponent fire after reactcomponent rendered. question how send data function component
i think can use event listener purpose. here great answer on react , event listeners. there react-event-listener library can check out.
Comments
Post a Comment