Reputation: 165
I read https://blog.nativebase.io/the-caveats-of-using-navigator-in-react-native-9547d99172ce#.cghvxk1mo
using react-native-router-flux for navigator but when I using it with nativebase. Component of nativebase not active
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import { AppRegistry,Text,View,Navigator } from 'react-native';
import { Container,Header,Content,Title,Badge,Tabs,Button,Icon} from 'native-base';
import { Router, Scene } from 'react-native-router-flux';
import Home from './component/Home';
import MyScene from './component/MyScene';
class CookApp extends Component {
//State la bien dung de luu giu trang thai. Con props la bien dung de trung chuyen du lieu, ham giua cac component
//dat ten class phai viet hoa dau, ten file phai trung file class
render() {
return (
<Router hideTabBar={true}>
<Scene key="PageOne" component={Home} title="Home" initial={true} />
<Scene key="pageTwo" component={MyScene} title="MyScene" />
</Router>
);
}
}
AppRegistry.registerComponent('CookApp', () => CookApp);
file: Home.js
import React, { Component, PropTypes } from 'react';
import { View, Text, TouchableHighlight } from 'react-native';
import { Container,Header,Content,Title,Badge,Tabs,Button,Icon,Input} from 'native-base';
import { Actions } from 'react-native-router-flux';
export default class Home extends Component {
render() {
const goToPageTwo = () => Actions.pageTwo({text: 'Hello World!'});
return (
<Header>
<Button>
<Icon name='ios-arrow-back' />
</Button>
<Title>CookApp</Title>
<Button>
<Icon name='ios-menu' />
</Button>
</Header>
<Container>
<Content>
<Button transparent onPress={Actions.pageTwo}>
go to pageTwo
</Button>
<View style={{margin: 128}}>
<Text onPress={goToPageTwo}>This is PageOne!</Text>
</View>
</Content>
</Container>
)
}
}
File : My scene.js
import React, { Component, PropTypes } from 'react';
import { View, Text, TouchableHighlight } from 'react-native';
import { Container,Header,Content,Title,Badge,Tabs,Button,Icon} from 'native-base';
import { Actions } from 'react-native-router-flux';
export default class MyScene extends Component {
// static propTypes = {
// title: PropTypes.string.isRequired,
// onForward: PropTypes.func.isRequired,
// onBack: PropTypes.func.isRequired,
// }
render() {
return (
// <Container>
// <Header>
// <Button transparent onPress={this.props.onBack}>
// <Icon name='ios-arrow-back' />
// </Button>
// <Title> { this.props.title }</Title>
// <Button transparent onPress={this.props.onForward}>
// <Icon name='ios-menu' />
// </Button>
// </Header>
//
// <Content>
// <Button transparent onPress = {this.deleteText}>
// <Icon name='ios-home' />
// </Button>
// </Content>
// </Container>
<View style={{margin: 128}}>
<Text>This is PageTwo!</Text>
<Text>{this.props.text}</Text>
</View>
)
}
}
When running app. Component of nativeBase not active.
Anyone used nativeBase with react-native-router-flux. please give me an example! Thanks for any help!
Upvotes: 5
Views: 2439
Reputation: 4893
find the latest example at https://github.com/vijaychouhan-rails/AllInOne/
I hope this will give you better understanding how to use NativeBase with react-native-router-flux
Upvotes: 0
Reputation: 1155
NativeBase has nothing to do with react-native-router-flux
. So that must be simple and straight forward.
Native-Starter-Kit (NSK) previously implemented NativeBase with react-native-router-flux
.
Due to enhancing features of React Native, NSK replaced react-native-router-flux with React Native Navigator.
Also, very soon NSK will implement Navigator Experimental.
Upvotes: 2