React Pass function to child component

前端 未结 4 1930
轮回少年
轮回少年 2020-12-05 11:38

I want to pass a function to a child component but I\'m getting this error.

Invalid value for prop passedFunction on

tag.

c         


        
4条回答
  •  失恋的感觉
    2020-12-05 12:19

    If you can bind this function like this it will works

    class Parent extends Component {
       passedFunction = () => {};
       render() {
       ;
      }
    }
    
    class Child extends Component {
       render() {
       
    ; } }

提交回复
热议问题