在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
}
}
我在做什么错了?