react-native-navigation的迁移库

WelcomeScreen.js 958B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import React, { Component } from 'react';
  2. import { View, Text, Button } from 'react-native';
  3. import Navigation from 'react-native-navigation';
  4. class WelcomeScreen extends Component {
  5. render() {
  6. return (
  7. <View style={styles.root}>
  8. <Text style={styles.h1}>{`React Native Navigation!`}</Text>
  9. <Button title="Switch to tab based app" onPress={this.onClickSwitchToTabs} />
  10. </View>
  11. );
  12. }
  13. onClickSwitchToTabs() {
  14. Navigation.startApp({
  15. tabs: [
  16. {
  17. container: {
  18. name: 'com.example.SimpleTabScreen'
  19. }
  20. },
  21. {
  22. container: {
  23. name: 'com.example.WelcomeScreen'
  24. }
  25. }
  26. ]
  27. });
  28. }
  29. }
  30. export default WelcomeScreen;
  31. const styles = {
  32. root: {
  33. flexGrow: 1,
  34. justifyContent: 'center',
  35. alignItems: 'center',
  36. backgroundColor: '#f5fcff'
  37. },
  38. h1: {
  39. fontSize: 24,
  40. textAlign: 'center',
  41. margin: 10
  42. }
  43. };