react-constant

2.0.1 • Public • Published

react-constant

Fuck off constants.js and global constants in react/flux/redux/wateva.

Feature

  • Drop all of your files about constants, react-constant will take care for you.
  • Namespaced constants, never worry about conflict with other component in your project.
  • 2.2KB minified, extreme slim.

build status npm version Coverage Status

Usage

Install

npm install react-constant --save

Import & Instance

Webpack/Browserify

//ES5 version
var Contant = require('react-constant');
var constants = Constant('mynamespace');
 
//ES6 version
import Constant from 'react-constant';
const constants = Constant('mynamespace');
 

browser

<script src="dist/constant.min.js"></script>

Just do it

reducer.js

function reducer(state, action){
  switch(action.type){
  case constants.of('ON'):
    //TODO
    break;
  case constants.of('OFF'):
    //TODO
    break;
  default: 
    return state;
  }
}

action.js

function toggleLight(flag){
  return {
    type: constants.ON,
    flag: flag
  }
}

Thanks

  • Redux for build and test template

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.12latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.12
2.0.00
1.2.30
1.2.20
1.2.00
1.1.20
1.1.10
1.1.00
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i react-constant

Weekly Downloads

2

Version

2.0.1

License

MIT

Last publish

Collaborators

  • jogis