Socket
Socket
Sign inDemoInstall

react-immutable-proptypes

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-immutable-proptypes

PropType validators that work with Immutable.js.


Version published
Weekly downloads
419K
increased by3.58%
Maintainers
1
Weekly downloads
 
Created

What is react-immutable-proptypes?

The react-immutable-proptypes package provides PropTypes validators that are specifically designed to work with Immutable.js data structures. This allows developers to enforce the types of Immutable.js collections in their React components, ensuring that the data passed through props adheres to the expected structure.

What are react-immutable-proptypes's main functionalities?

List

This feature allows you to validate that a prop is an Immutable.js List. The code sample demonstrates a React component that expects a prop named `myList` to be an Immutable List.

import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { List } from 'immutable';

const MyComponent = ({ myList }) => (
  <div>{myList.join(', ')}</div>
);

MyComponent.propTypes = {
  myList: ImmutablePropTypes.list
};

export default MyComponent;

Map

This feature allows you to validate that a prop is an Immutable.js Map. The code sample demonstrates a React component that expects a prop named `myMap` to be an Immutable Map.

import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { Map } from 'immutable';

const MyComponent = ({ myMap }) => (
  <div>{myMap.get('key')}</div>
);

MyComponent.propTypes = {
  myMap: ImmutablePropTypes.map
};

export default MyComponent;

OrderedMap

This feature allows you to validate that a prop is an Immutable.js OrderedMap. The code sample demonstrates a React component that expects a prop named `myOrderedMap` to be an Immutable OrderedMap.

import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { OrderedMap } from 'immutable';

const MyComponent = ({ myOrderedMap }) => (
  <div>{myOrderedMap.get('key')}</div>
);

MyComponent.propTypes = {
  myOrderedMap: ImmutablePropTypes.orderedMap
};

export default MyComponent;

Set

This feature allows you to validate that a prop is an Immutable.js Set. The code sample demonstrates a React component that expects a prop named `mySet` to be an Immutable Set.

import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { Set } from 'immutable';

const MyComponent = ({ mySet }) => (
  <div>{Array.from(mySet).join(', ')}</div>
);

MyComponent.propTypes = {
  mySet: ImmutablePropTypes.set
};

export default MyComponent;

Other packages similar to react-immutable-proptypes

Keywords

FAQs

Package last updated on 13 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc