react-native-meteor-router-flux
v1.1.0
Published
Full Meteor Client for React Native - Plugin for react-native-router-flux
Downloads
19
Maintainers
Readme
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 ! :)