GithubHelp home page GithubHelp logo

react-navigation-redux's Introduction

React Navigation Redux

Simple React Navigation wrapper for easier Redux integration for those who prefers "one router one state" approach.

Usage

Creating Routes

For routing, you can use either:

  • TabNavigator
  • StackNavigator
  • DrawerNavigator (not tested yet)

Specify your route configs, stack navigator configs or tab navigator configs, and the name of your Redux reducer key that holds the state for that particular route.

import {TabNavigator, StackNavigator, DrawerNavigator} from 'react-navigation-redux';

let Router1 = TabNavigator(routeConfigs, navigatorConfigs)('tabReducerKey');
let Router2 = StackNavigator(routeConfigs, navigatorConfigs)('stackReducerKey');
let Router3 = DrawerNavigator(routeConfigs, navigatorConfigs)('drawerReducerKey');

Adding Reducers

Then on your root reducer, import your router and navigationReducer.

import {navigationReducer} from 'react-navigation-redux';
import {combineReducers} from 'redux';

import Router1 from './your/router/path/';
import Router2 from './your/router/path/';
import Router3 from './your/router/path/';

export default combineReducers({
  tabNavigationState: navigationReducer(Router1),
  stackNavigationState: navigationReducer(Router2),
  drawerNavigationState: navigationReducer(Router3),
});

Changing Route

List of navigation actions is stated in the react navigation docs.

Here are some of the basic actions you can do:

// navigate to a route
{
  type: 'Navigation/NAVIGATE',
  routeName: 'foo',
  params: {}
}

// navigate back
{
  type: 'Navigation/BACK',
}

Basically the action types are:

Action Type
"Navigation/NAVIGATE"
"Navigation/BACK"
"Navigation/INIT"
"Navigation/RESET"
"Navigation/SET_PARAMS"
"Navigation/URI"

That's it! :)

react-navigation-redux's People

Contributors

rvlewerissa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.