0.2.13 • Published 7 years ago

raininfall.rax-navigation v0.2.13

Weekly downloads
3
License
BSD-3-Clause
Repository
github
Last release
7 years ago

rax-navigation npm

Install

npm install --save rax-navigation

Usage

import {render, createElement, Component} from 'rax';
import {StackNavigator} from 'rax-navigation';
import Button from 'rax-button';

class MainScreen extends Component {
  static navigationOptions = {
    title: 'Welcome'
  };
  render() {
    const { navigate } = this.props.navigation;
    return (
      <Button
        title="Go to Jane's profile"
        onPress={() => {
          navigate('Profile', { name: 'Jane' })
        }}
      />
    );
  }
}

class ProfileScreen extends Component {
  static navigationOptions = {
    title: ({state}) => state.params.name,
    header: false
  };
  render() {
    const { goBack } = this.props.navigation;
    return (
      <Button
        title="Go back"
        onPress={() => goBack()}
      />
    );
  }
}

const BasicApp = StackNavigator({
  Main: {screen: MainScreen},
  Profile: {screen: ProfileScreen},
});

render(<BasicApp />);