0.1.0 • Published 6 years ago

redux-onoff v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

alt redux-onoff-tiny REDUX ON/OFF

alt redux-onoff-tiny

This repository contains redux-onoff source code and currently hosted on Github. The main purpose of redux-onoff is to easily set toggle options to components connected to a Redux store.

It will be very useful for components like dialog window, switch button and etc.

Installation

  • yarn

    yarn add redux-onoff
  • npm

    npm install redux-onoff

Getting Started

// in src/some/reducer.js
import { hor } from "redux-onoff";

const counterInit = { counter: 0 };
const someReducer = (state = counterInit, action = {}) => { ... };
export const newSomeReducer = hor("some")(someReducer);

// in src/App.js
import React, { Component } from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { toggleAction, setAction } from "redux-onoff";
import * as actions from "./yourReduxActions";

class App extends Component {
  ...
}

export default connect(
  mapStateToProps,
  dispatch => bindActionCreators(
    {
      ...actions,
      toggleWindow: toggleAction("some"),
    },
    dispatch
  )
)(App);