React.js communicate with state object from outside component


Using the React DnD lib:

const itemDropTarget = {
    acceptDrop(component, item) {
        window.alert('You dropped ' + + '!');

const Container = React.createClass({

    mixins: [DragDropMixin],

    getInitialState() {
        return {
            items: []

    statics: {
        configureDragDrop(register) {
            register(ItemTypes.ITEM, {
                dropTarget: itemDropTarget

Wondering how I can add the new "dropped" item into my React component's state object, from the acceptDrop function? What's the usual approach for this kind of thing with React?


The normal way is using callbacks , you create the function inside the parent component and then put it as props when you call the child.

This video can help you solving your question :)
By: admin