with-immutable-props-to-js
![Logo](https://github.com/tophat/with-immutable-props-to-js/raw/HEAD/./website/static/img/ml.png)
![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=tophat/with-immutable-props-to-js)
![Maturity badge - level 3](https://img.shields.io/badge/Maturity-Level%203%20--%20Stable-green.svg)
A higher-order component for keeping Immutable objects outside your presentational components
Installation
yarn add with-immutable-props-to-js
or
npm install with-immutable-props-to-js
This library also lists react
, react-dom
, and immutable
as peer dependencies, so make sure they are installed in your project as well.
Usage
import withImmutablePropsToJS from 'with-immutable-props-to-js'
If you're not using ECMAScript modules:
const withImmutablePropsToJS = require('with-immutable-props-to-js').default
Example:
import React from 'react'
import { connect } from 'react-redux'
import withImmutablePropsToJS from 'with-immutable-props-to-js'
const MyDumbComponent = props => {
}
MyDumbComponent.propTypes = {
objectProp: PropTypes.object,
arrayProp: PropTypes.array,
}
const mapStateToProps = state => ({
objectProp: mySelectorThatReturnsImmutableMap(state),
arrayProp: mySelectorThatReturnsImmutableList(state),
})
export default connect(mapStateToProps)(withImmutablePropsToJS(MyDumbComponent))
Motivation
You can read about the rationale for this higher-order component here.
Contributors
For information on how to contribute to this project, check out the contributing guide.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
Special thanks to Carol Skelly for donating the 'tophat' GitHub organization.