2.0.1 • Published 9 years ago
react-constant v2.0.1
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.
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
2.0.1
9 years ago
2.0.0
9 years ago
1.2.3
9 years ago
1.2.2
10 years ago
1.2.0
10 years ago
1.1.2
10 years ago
1.1.1
10 years ago
1.1.0
10 years ago
1.0.9
10 years ago
1.0.8
10 years ago
1.0.7
10 years ago
1.0.6
10 years ago
1.0.5
10 years ago
1.0.4
10 years ago
1.0.3
10 years ago
1.0.2
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago