1.1.0 • Published 8 years ago

immutable-props v1.1.0

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

immutable-props NPM version Downloads Build Status

Information

  • This provides React PropTypes for Immutable.js data.
  • This is the equivalent of React.PropTypes.instanceOf(Immutable.Type) so you can do all the normal stuff
    • .isRequired, nest in .oneOfType, etc.
  • React and Immutable are peer dependencies, so this will not install those for you.
    • This module works with any version of React and Immutable you have installed! :beer:

Install

npm install immutable-props --save

Available Types

  • Iterable
  • Seq
  • Collection
  • Map
  • OrderedMap
  • List
  • Stack
  • Set
  • OrderedSet
  • Record
  • Range
  • Repeat
  • Cursor

Example

ES5

var IPropTypes = require('immutable-props');

var UserPage = React.createClass({
  propTypes: {
    user: IPropTypes.Map,
    friends: IPropTypes.List
  },
  render: function() {
    // ...
  }
});

ES6

import IPropTypes from 'immutable-props'

class UserPage extends React.Component {
  static propTypes = {
    user: IPropTypes.Map,
    friends: IPropTypes.List
  };

  render () {
    // ...
  }
}

ES6 (with destructuring)

import { Map, List } from 'immutable-props'

class UserPage extends React.Component {
  static propTypes = {
    user: Map,
    friends: List
  };

  render () {
    // ...
  }
}