Nimble Pixie Merchant

    @lighthouseapps/react-native-dva

    1.2.6 • Public • Published

    react-native-dva

    React Native Dva for Android and iOS

    Getting started

    $ npm i @lighthouseapps/react-native-dva --save

    Usage

    // ./src/models/app.js
    export default {
      namespace: 'app',
      state: {},
      effects: {},
      reducers: {},
      subscriptions: {}
    };
    
    // ./src/models/index.js
    import app from './app';
    
    export default [
      app
    ];
    
    // ./src/router.js
    import {
      LoadingScreen,
      SigninScreen,
      HomeScreen
    } from './screens';
    import {
      AppLayout
    } from './layouts';
    
    export default {
      type: 'switch',
      routes: [
        {
          type: 'screen',
          name: 'Loading',
          layout: null,
          component: LoadingScreen
        },
        {
          type: 'screen',
          name: 'Signin',
          layout: null,
          component: SigninScreen
        },
        {
          type: 'stack',
          name: 'App',
          layout: null,
          routes: [
            {
              type: 'screen',
              name: 'Books',
              layout: null,
              component: HomeScreen
            }
          ],
          options: {}
        }
      ],
      layout: AppLayout,
      options: {}
    }
    
    // index.js
    import React from 'react';
    import dva, {
      createRouter
    } from 'react-native-dva';
    import App from './App';
    import models from './src/models';
    import router from './src/router';
    import {
      name
    } from './app.json';
    
    const {
      routerMiddleware,
      routerReducer,
      Router
    } = createRouter(router);
    
    const app = dva({
      models,
      extraReducers: { router: routerReducer },
      onAction: [ routerMiddleware ]
    });
    
    app.start(name, <Router />);

    Install

    npm i @lighthouseapps/react-native-dva

    DownloadsWeekly Downloads

    9

    Version

    1.2.6

    License

    MIT

    Unpacked Size

    20.9 kB

    Total Files

    17

    Last publish

    Collaborators

    • leosampc
    • marlonconstante
    • gustavo-kuze
    • donnes
    • alvarosilveiraa
    • lhdev