Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何使用react native中的道具从父组件到子组件使用方法? const祖父母=(道具)=>{ 常数关闭=()=>{ 控制台日志(“按下”); } 返回(close()}/>) } 常量父项=(道具)=>{ 返回() } const Child=(道具)=>{ 返回(props.onPress}/>) }_Reactjs_React Native_React Hooks - Fatal编程技术网

Reactjs 如何使用react native中的道具从父组件到子组件使用方法? const祖父母=(道具)=>{ 常数关闭=()=>{ 控制台日志(“按下”); } 返回(close()}/>) } 常量父项=(道具)=>{ 返回() } const Child=(道具)=>{ 返回(props.onPress}/>) }

Reactjs 如何使用react native中的道具从父组件到子组件使用方法? const祖父母=(道具)=>{ 常数关闭=()=>{ 控制台日志(“按下”); } 返回(close()}/>) } 常量父项=(道具)=>{ 返回() } const Child=(道具)=>{ 返回(props.onPress}/>) },reactjs,react-native,react-hooks,Reactjs,React Native,React Hooks,我可以使用道具从父组件调用祖父母的组件方法,但我想从子组件调用它,我似乎做不到。它应该是这样工作的: const祖父母=(道具)=>{ 常数关闭=()=>{ 控制台日志(“按下”) } 返回(close()}/>) } 常量父项=(道具)=>{ 返回(props.func()}/>) } const Child=(道具)=>{ 返回(props.func()}/>) } const祖父母=(道具)=>{ 常数关闭=()=>{ 控制台日志(“按下”); } 返回(close()}/>) } 常量父

我可以使用
道具
父组件调用
祖父母的组件方法,但我想从
子组件调用它,我似乎做不到。

它应该是这样工作的:

const祖父母=(道具)=>{
常数关闭=()=>{
控制台日志(“按下”)
}
返回(close()}/>)
}
常量父项=(道具)=>{
返回(props.func()}/>)
}
const Child=(道具)=>{
返回(props.func()}/>)
}
const祖父母=(道具)=>{
常数关闭=()=>{
控制台日志(“按下”);
}
返回(close()}/>)
}
常量父项=(道具)=>{
返回(props.func()}fun1={()=>props.func()}/>)
}
const Child=(道具)=>{
返回(props.func1()}/>)
}
const GrandParent = (props) => {
  const close = () => {
    console.log("Pressed");
  }
 return (<Parent func={() => close()} />)
}

const Parent = (props) => {
  return (<Child onPress={()=> props.func()} fun1={()=> props.func()}/>)
}

const Child = (props) => {
  return (<Button onPress={()=> props.func1()} />)
}