如何在REACT NATIVE中将方法传递给this.props.children



我需要通过react native中的{this.props.children}将一个方法从父组件传递到子组件。

我试过

{React.cloneElement(this.props.children, { lang: "en" })}

但这只是一个错误。你知道如何在react native中做到这一点吗?

export default function ComponentA(props){
return(
<View style={{backgroundColor: "red"}}>
{props.children}
</View>
);
};

<ComponentA>
<Text>THIS TEXT WILL HAVE A RED BACKGROUND</Text>
</ComponentA>

最新更新