React DnD:DropTarget悬停方法中未定义组件方法

时间:2018-07-27 14:39:57

标签: reactjs react-dnd

在DropTarget的悬停方法中,我需要将组件函数传递给item。但是所有组件函数都未定义,但道具还可以:

const questionEditTarget = {
    hover(props, monitor, component) {
        //some code
        monitor.getItem().deleteQuestionEdit = component._deleteQuestionEdit;
        //component._deleteQuestionEdit is undefined.
    } 
}

}

我的组件看起来像这样:

export class QuestionGroupEdit extends Component {
    _deleteQuestionEdit = (index) => {
            let questions = Object.assign([], this.props.questions);
            questions.splice(index, 1);
            this.props.handleGroupChange(questions, this.props.index);
    }
    render() {
        //render code
    }
}

我在做什么错了?

0 个答案:

没有答案