GithubHelp home page GithubHelp logo

seventhunders07 / react-navigation-mobx-helpers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from el-psy-k/react-navigation-mobx-helpers

0.0 1.0 0.0 25 KB

React-Navigation bindings for MobX

License: MIT License

TypeScript 100.00%

react-navigation-mobx-helpers's Introduction

react-navigation-mobx-helpers

React-Navigation bindings for MobX

Installation

npm install react-navigation-mobx-helpers --save

Usage

import React from 'react';
import { Provider, inject, observer } from 'mobx-react';
import { StackNavigator } from 'react-navigation';
import NavigationStore from 'react-navigation-mobx-helpers';

const RootNavigator = StackNavigator(RouteConfigs);

const rootNavigation = new NavigationStore();

class Root extends React.Component {
  render() {
    return (
      <Provider rootNavigation={rootNavigation}>
        <App />
      </Provider>
    );
  }
}

@inject('rootNavigation')
@observer
class App extends React.Component {
  render() {
    const { rootNavigation } = this.props;
    return <RootNavigator ref={rootNavigation.createRef} />;
  }
}

API

Action Parameter Description
createRef ref: React.Component Save an instance of navigation to store
dispatch action: NavigationAction Send an action to router
getParam paramName: string, fallback?: NavigationParams Get a specific param with fallback
setParams newParams: NavigationParams Make changes to route's params
navigate { routeName: string, params?: NavigationParams, action?: NavigationAction, key?: string } OR routeName: string, params?: NavigationParams, action?: NavigationAction Go to another screen, figures out the action it needs to take to do it
push routeName: string, params?: NavigationParams, action?: NavigationAction Navigate forward to new route in stack
replace routeName: string, params?: NavigationParams, action?: NavigationAction Replace the current route with a new one
goBack routeKey?: string | null Close active screen and move back in the stack
pop n?: number, params?: { immediate?: boolean } Go back in the stack
popToTop params?: { immediate?: boolean } Go to the top of the stack

react-navigation-mobx-helpers's People

Contributors

el-psy-k avatar seventhunders07 avatar dimous avatar

Watchers

 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.