React.js how to pass callbacks to child components?

后端 未结 2 1841
深忆病人
深忆病人 2020-12-14 15:42

I would like to pass a callback to a doubly nested component, and while I am able to pass the properties effectively, I can\'t figure out how to bind the callback to the cor

2条回答
  •  自闭症患者
    2020-12-14 16:28

    You are passing this.onUserInput as a property to FirstNestedComponent. Therefore, you should access it in FirstNestedComponent as this.props.onUserInput.

    var FirstNestedComponent = React.createClass({
        render: function() {
            return (
                
    ); } });

提交回复
热议问题