javascript - React.js communicate with state object from outside component -


using react dnd lib:

const itemdroptarget = {     acceptdrop(component, item) {         window.alert('you dropped ' + item.name + '!');     } };  const container = react.createclass({      mixins: [dragdropmixin],      getinitialstate() {         return {             items: []         };     },      statics: {         configuredragdrop(register) {             register(itemtypes.item, {                 droptarget: itemdroptarget             });         }     } }); 

wondering how can add new "dropped" item react component's state object, acceptdrop function? what's usual approach kind of thing react?

the normal way using callbacks , create function inside parent component , put props when call child.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -