react-native-meteor-router-flux

1.1.0 • Public • Published

GitHub version npm version Dependency Status devDependency Status MIT bitHound Score

react-native-meteor-router-flux

Plugin for react-native-meteor.

Custom scene renderer which allows to select tab scene to show depending from app state. It could be useful for authentication, restricted scenes, etc.

Install

npm i --save react-native-meteor-router-flux@latest

Example usage

 
'use strict';
 
import React, { Component } from 'react-native';
import { Actions, Scene, Router } from 'react-native-router-flux';
import Meteor from 'react-native-meteor';
import { meteorSwitch } from 'react-native-meteor-router-flux';
 
export default class RouterContainer extends Component {
  render () {
 
    const getMeteorData = ()=>{
      return {
        connected: Meteor.status().connected,
        user: Meteor.user(),
        loggingIn: Meteor.loggingIn()
      }
    };
 
    const selector = (data, props) => {
      if(!data.connected || data.loggingIn) {
        return "loading";
      } else if (!data.user) {
        return "login";
      } else {
        return "loggedIn";
      }
 
    };
 
    const scenes = Actions.create(
      <Scene key="root" component={meteorSwitch(getMeteorData)} selector={selector} tabs={true}>
        <Scene key="loading" component={Loading} />
        <Scene key="login" component={Login} />
 
        <Scene key="loggedIn">
          <Scene key="home" component={Home} />
          <Scene key="settings" component={Settings} />
        </Scene>
      </Scene>
    );
 
 
    return (
      <Router scenes={scenes} />
    );
  }
}
 

Pull Requests are welcome ! :)

Package Sidebar

Install

npm i react-native-meteor-router-flux

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • theo-mathieu