javascript - In Reactjs, how to send and respond to user defined event? -


in reactjs, how send user defined event? , response user defined event? can please give example? e.g. user.newitemaddtocart

below code example responding standard dom event.

var addfriend = react.createclass({   getinitialstate: function(){     return {       newfriend: ''     }   },   updatenewfriend: function(e){     this.setstate({       newfriend: e.target.value     });   },   handleaddnew: function(){     this.props.addnew(this.state.newfriend);     this.setstate({       newfriend: ''     });   },   render: function(){     return (         <div>           <input type="text" value={this.state.newfriend} onchange={this.updatenewfriend} />           <button onclick={this.handleaddnew}> add friend </button>           <span onuser.newitemaddtocart= {...}> work?</span>         </div>     );   } }); 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -