https://github.com/pindlebot/react-valid-attributes
https://github.com/pindlebot/react-valid-attributes
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pindlebot/react-valid-attributes
- Owner: pindlebot
- Created: 2018-03-30T05:23:31.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-29T01:34:17.000Z (over 7 years ago)
- Last Synced: 2025-09-26T13:03:22.224Z (9 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## 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](https://www.npmjs.com/package/react-html-attributes).
## Example
```js
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 }