反应导航 - 选项卡导航 - 仅从一个类获取不同的屏幕

时间:2018-04-13 10:35:22

标签: react-native react-navigation

可以在标签之间进行更改而不需要多一个课程?

在我的代码中,我有一个返回多个组件的类,我希望我的TabNavigator在这些组件之间切换,而不是像在React Navigation文档(https://reactnavigation.org/docs/tab-based-navigation.html)中那样在类之间切换。

class Monument extends Component{
    render(){
        const {navigate} = this.props.navigation;
        const { data } = this.props.navigation.state.params;

        return (
            <MonumentMaker category={'Castelos'} navigate={navigate} data={data}/>
            <MonumentMaker category={'Museus'} navigate={navigate} data={data}/>
            <MonumentMaker category={'Igrejas'} navigate={navigate} data={data}/>
            <MonumentMaker category={'Locais de Interesse'} navigate={navigate} data={data}/>
        );
    }
}

export default TabNavigator({
  Convento: {
    screen:**first component**
  },
  Museus: {
    screen:**second component**
  },
  Igrejas: {
    screen:**third component**
  },
  OutrosLocais: {
    screen:**forth component**
  }
})

我想要完成的是什么?

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

您可以按照以下方式设置$(document).on('submit', 'form', function() { setTimeout(function() { window.location = "/thanks.html"; }, 1000); });

TabNavigation

<强> Monument.js

const myTabNavigator = TabNavigator({
   Convento: {
    screen: { screen: props => <Monument {...props} {...myProps} /> }
  },
  Museus: {
    screen: { screen: props => <Monument {...props} {...myProps} /> }
  },
  Igrejas: {
    screen: { screen: props => <Monument {...props} {...myProps} /> }
  },
  OutrosLocais: {
    screen: { screen: props => <Monument {...props} {...myProps} /> }
  }
})