Skip to content

inProgress-team/react-native-meteor-router-flux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub version npm version Dependency Status devDependency Status MIT bitHound Score

DEPRECATED

This plugin is deprecated since react-native-meteor createContainer works with react-native-router-flux Switch component (see https://github.com/inProgress-team/react-native-meteor/blob/master/README.md#react-native-router-flux) for informations

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 ! :)