Package Exports
- redux-connected-proptypes
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-connected-proptypes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Redux Connected PropTypes
PropTypes are a great development tool in React
. Redux is an amazing module for maintaining a single global state for your application. Why not use both together? Redux Connected PropTypes consumes a react component(with propTypes) and returns a connected
version of that component in react-redux
parlance with the props defined on the compoents propTypes
injected into the component instance from the redux global state.
NOTE: ONLY WORKS WITH ES6 CLASS COMPONENTS AND FUNCTIONAL COMPONENTS
Install
npm i redux-connected-proptypes --save
Args
component
- the React Component with propTypes defined to be injected from global redux state.ignored
- an optional array of propType definitions that you do not want injected from global state.
How To Use
For a more in depth example see here
This example assumes you are using redux and have rendered your app wrapped in Provider
import React from 'react';
import reduxConnectedPropTypes from 'redux-connected-proptypes';
const Animals = ({animals}) => {
return (
<ul>
{animals.map((animal) => {
return <li key={animal}>{animal}</li>
})}
</ul>
);
}
Animals.propTypes = {
animals: React.PropTypes.array.isRequired
};
export default reduxConnectedPropTypes(Animals);