Giter Club home page Giter Club logo

redux-flipper's Introduction

Redux Flipper

screenshot of the plugin

Redux middleware for Flipper. It can log redux actions and show inside Flipper using flipper-plugin-redux-debugger.

Support

  • React Native
    • For react-native >= 0.62, flipper support is enabled by default
    • For react-native < 0.62, follow these steps to setup your app
  • Redux or Redux-Toolkit

Get Started

  1. Install redux-flipper middleware and react-native-flipper in your React Native app:
yarn add redux-flipper react-native-flipper
# for iOS
cd ios && pod install
  1. Add the middleware into your redux store:
import { createStore, applyMiddleware } from 'redux';

const middlewares = [
  /* other middlewares */
];

if (__DEV__) {
  const createDebugger = require('redux-flipper').default;
  middlewares.push(createDebugger());
}

const store = createStore(RootReducer, applyMiddleware(...middlewares));
  1. Install flipper-plugin-redux-debugger in Flipper desktop client:
Manage Plugins > Install Plugins > search "redux-debugger" > Install
  1. Start your app, then you should be able to see Redux Debugger on your Flipper app

Optional Configuration

State whitelisting

Many times you are only interested in certain part of the Redux state when debugging. You can pass array of string which have to match to the root key of the Redux state.

For example if Redux schema is something like this and you are only interested in user then you can whitelist only that part of the state

type ReduxState = {
  todos: string[];
  notifications: string[];
  user: {
    name: string;
  };
};
let reduxDebugger = createDebugger({ stateWhitelist: ['user'] });

If you app has very big state tree it is also good idea to whitelist certain keys from Redux state otherwise Flipper can be very slow.

Resolve cyclic reference

Redux Debugger does not support cyclic reference objects by default as resolving it makes application slow. This feature can be enabled by passing { resolveCyclic: true } into createDebugger.

This is just a temporary solution if debugging is urgent. It is advisable to restructure your redux state structure.

For more information about cyclic reference, visit MDN Cyclic Object.

let reduxDebugger = createDebugger({ resolveCyclic: true });

Actions Blacklist

You may specify an actions blacklist the same way as with React Native Debugger, by providing an array of strings to match against the action.type field. This feature can be enabled by passing { actionsBlacklist } into createDebugger, where actionsBlacklist is an array of strings.

For example:

const actionsBlacklist = ['EVENTS/', 'LOCAL/setClock'];
const reduxDebugger = createDebugger({ actionsBlacklist });

This will exclude any actions that contain the substrings in the blacklist. So an action with type EVENTS/foo will not be sent to the redux debugger flipper plugin, but an action with type LOCAL/anotherAction will.

redux-flipper's People

Contributors

jk-gan avatar plwai avatar henrikra avatar dependabot[bot] avatar andrewzey avatar ferrannp avatar mikaoelitiana avatar appden avatar bell-steven avatar joe-goodall-ticketmaster 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.