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
Post a Comment