React Native pass function to child component as prop

前端 未结 3 1654
面向向阳花
面向向阳花 2021-01-11 22:57

I\'m new to React Native (and React), and I\'m trying to pass a function as a prop to a component.

My goal is to create a component where its onPress functionality c

3条回答
  •  Happy的楠姐
    2021-01-11 23:17

    // Parent
    
    handleClick( name ){
       alert(name);
    }
    
    
    
    // Children
    
    let { func } = this.props;
    
    func( 'VARIABLE' );
    

提交回复
热议问题