简体   繁体   English

如何将 function navigation.goBack() 传递给组件

[英]how pass a function navigation.goBack() to component

how i can pass a function navigation.goBack() to component child我如何将 function navigation.goBack() 传递给子组件

Next code:下一个代码:

Parent家长

<SafeAreaView style={{ flex: 1 }}>
        <ModalLoading visible={loading} />
        <KeyboardAwareScrollView
            innerRef={ref => scrollRef}
            contentContainerStyle={{ flexGrow: 1 }}
            style={styles.container}>

            <HeaderCadastro
                navigation={() => navigation.goBack()}
            />

Child孩子

            <Pressable onPress={navigation} style={style.backButton}>
                <Icon name='chevron-back' size={moderateScale(30)} />
            </Pressable>

Change your parent and child as this:将您的父母和孩子更改为:
parent:家长:

<HeaderCadastro  navigation={navigation.goBack} />

child:孩子:

<Pressable onPress={() => navigation()} style={style.backButton}>
                <Icon name='chevron-back' size={moderateScale(30)} />
            </Pressable>

explanation:解释:

There were only syntax errors, not major issues.只有语法错误,没有重大问题。
You just to have to remember how to call it and how to pass it.你只需要记住如何调用它以及如何传递它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查 goBack() function 在反应导航中是否可行? - how to check if goBack() function is doable in react navigation? 使用 navigation.goBack 关闭屏幕会延迟到我的繁重任务完成 - Dismissing a screen with navigation.goBack is delayed until my heavy task finishes React Native:navigation.goBack() 返回到其他 createStackNavigator 屏幕而不是前一个屏幕 - React Native: navigation.goBack() returns to other createStackNavigator screen instead of previous screen 将 function 传递给导航组件 - pass a function to navigation component 如何将高阶组件传递给 React Navigation? - How to pass higher order component to React Navigation? 从子屏幕到达导航挂钩时,如何刷新父屏幕并获取旧的 state 值? - How to refresh the parent screen and get old state values when using Goback function from child screen Reach Navigation Hooks? 如何通过 React Navigation 将导航道具传入功能组件屏幕? - How to pass in navigation props into a functional component screen through React Navigation? React Router hashHistory goBack函数如何工作 - How React router hashHistory goBack function works 如何在反应导航 v5 中将导航道具传递给子组件 - How to pass navigation prop to child component in react navigation v5 如何从路由器goback维护反应组件状态? - How to maintain react component state when goback from router?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM