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
React native 如何从抽屉导航器传递函数_React Native_React Navigation_Navigation Drawer_React Navigation Drawer - Fatal编程技术网

React native 如何从抽屉导航器传递函数

React native 如何从抽屉导航器传递函数,react-native,react-navigation,navigation-drawer,react-navigation-drawer,React Native,React Navigation,Navigation Drawer,React Navigation Drawer,我使用的是react导航v4。我有一个抽屉驱动程序,由三个按钮组成,假设每个按钮在特定页面中分配一个函数 我正在尝试如何将这些功能(如果可能的话)传递到所需的页面,这样我就可以在页面中调用函数,当按下抽屉中的按钮时,启动此函数 const SettingDrawer = createDrawerNavigator({ TaskEdit : { screen : TaskEditScreen, navigationOptions : {

我使用的是react导航v4。我有一个抽屉驱动程序,由三个按钮组成,假设每个按钮在特定页面中分配一个函数

我正在尝试如何将这些功能(如果可能的话)传递到所需的页面,这样我就可以在页面中调用函数,当按下抽屉中的按钮时,启动此函数

const SettingDrawer = createDrawerNavigator({
    TaskEdit : {
        screen : TaskEditScreen,
        navigationOptions : {
            title : 'Settings',
        },
    },
} , {
   drawerPosition : 'right',
   defaultNavigationOptions : defaultNavOptions,
   contentOptions : {
    activeTintColor : Colors.primary
   },
   contentComponent : (props) =>  <View style = {{marginVertical : 10}}>
      <Button 
      title = 'Set as Done' onPress = {props.done}
        titleStyle  = {{color : 'white' , fontFamily : 'header'}}
        buttonStyle = {{
            backgroundColor : Colors.primary,
            width : '80%',
            marginVertical : 10,
            alignSelf : 'center'
        }}
        icon ={ <Ionicons
        name = {Platform.OS === 'android' ? 'md-done-all' : 'ios-done-all'}
        size = {23}
        color  = 'white'
        style = {{marginRight : 20}}
        />}
        iconContainerStyle = {{marginRight : 10}}
        />
         <Button title = 'Close Task' onPress = {() => props.navigation.navigate('Reminders')}
            titleStyle  = {{color : 'white' , fontFamily : 'header'}}
            buttonStyle = {{
                backgroundColor : Colors.primary,
                width : '80%',
                marginVertical : 10,
                alignSelf : 'center'
            }}
            icon = {
                <Ionicons
                name = {Platform.OS === 'android' ? 'md-close' : 'ios-close'}
                size = {23}
                color  = 'white'
                style = {{marginRight : 20}}
                />
            }
            iconContainerStyle = {{marginRight : 10}}
            />
            <Button 
            {...props}
            title = 'Cancel' onPress = {() => props.navigation.toggleDrawer(
            )} 
                titleStyle  = {{color : 'white' , fontFamily : 'header'}}
                buttonStyle = {{
                    backgroundColor : Colors.primary,
                    width : '80%',
                    marginVertical : 10,
                    alignSelf : 'center'
                }}
            />
   </View>
})
const SettingDrawer=createDrawerNavigator({
任务编辑:{
屏幕:TaskEditScreen,
导航选项:{
标题:“设置”,
},
},
} , {
抽屉位置:'对',
defaultNavigationOptions:defaultNavOptions,
内容选项:{
activeTintColor:Colors.primary
},
contentComponent:(道具)=>
props.navigation.navigate('提醒')}
titleStyle={{color:'white',fontFamily:'header'}
按钮样式={{
背景颜色:Colors.primary,
宽度:“80%”,
玛吉:10,
自我定位:“中心”
}}
图标={
}
iconContainerStyle={{marginRight:10}
/>
props.navigation.toggleDrawer(
)} 
titleStyle={{color:'white',fontFamily:'header'}
按钮样式={{
背景颜色:Colors.primary,
宽度:“80%”,
玛吉:10,
自我定位:“中心”
}}
/>
})

您想在屏幕上设置参数吗?不,我想传递一个道具。我不完全理解您想要什么。您有3个按钮,但您想要传递什么,以及您只在代码中导航的确切位置。你想导航到提醒并传递道具吗?很抱歉让你困惑,我知道我让你困惑了。我需要的就像我们在父/子组件中所做的一样。例如(props.close)被传递,因此在包含抽屉导航器的页面中,我可以执行类似于close={myFunction]的操作。相应地,当用户打开抽屉并按下close时,它将执行一个close函数,我将在那里执行clare