Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

deepsweet/react-attrs-filter

Repository files navigation

npm travis coverage deps

Filter React props:

  • getPropsFor(tag)
  • filterPropsFor(props, tag)
  • filterPropsExcept(props, tag)

Install

npm i -S react-attrs-filter

Usage

import {
    getPropsFor,
    filterPropsFor,
    filterPropsExcept
} from 'react-attrs-filter';

console.log(
    getPropsFor('input')
);
// [ 'list', 'max', 'maxLength', 'min', 'multiple', … ]

console.log(
    filterPropsFor({ ololo: true, min: 0 }, 'input')
);
// { min: 0 }

console.log(
    filterPropsExcept({ ololo: true, min: 0 }, 'input')
);
// { ololo: true }

References