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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -