redux-proptypes-pack
v0.1.1
Published
Use React.PropTypes in your redux apps.
Downloads
4
Readme
redux-proptypes-pack
Use React.PropTypes
in your redux apps.
npm install redux-proptypes-pack
Usage
// reducers.js
import React from 'react';
import packCreator from 'redux-proptypes-pack';
const {PropTypes} = React;
const pack = packCreator();
const initialState = {
items: [{
title: '',
content: ''
}]
};
const validator = PropTypes.shape({
items: PropTypes.arrayOf(PropTypes.object)
});
function todoList(state = initialState, action){
// ...
}
export default pack(todoList, validator);
Disable validating in your production environment.
// reducers.js
import packCreator from 'redux-proptypes-pack';
const disabled = (process.env.NODE_ENV === 'production');
const pack = packCreator(disabled);
Then the pack
function will simplely pass your reducers to Redux.
API Reference
packCreator(disabled)
####Arguments
disabled
(Boolean): The returned pack
function won't validate when the disabled
is truthy.
####Returns
pack
(Function)
pack(reducer, validator)
####Arguments
reducer
(Function): A redux reducer.
validator
(Function): A validtor form React.PropTypes
.
Run tests
npm test
License
MIT