react-valid-attributes

0.0.2 • Public • Published

react-valid-attributes

Exports two functions:

  • pick: pick all valid html attributes from props for a given element
  • omit: omit all valid html attributes from props for a given element

Uses react-html-attributes.

Example

const { pick, omit }  = require('react-valid-attributes')
 
const props = {
  src: 'https://pbs.twimg.com/profile_images/765333670366355456/q5ACQ8i3_400x400.jpg',
  alt: 'The npm logo',
  handleImageClick: () => {}
}
 
const attributes = pick(props, 'img')
// => { src: '...', alt: '...' }
 
const rest = omit(props, 'img')
// => { handleImageClick }

Readme

Keywords

none

Package Sidebar

Install

npm i react-valid-attributes

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

2.4 kB

Total Files

4

Last publish

Collaborators

  • menubar