Allow a React component to accept `data-*` props and apply them to an element
MIT License
Allow a React component to accept
data-*
props and apply them to an element
yarn add react-data-props
Pass all unknown restProps
of your component into the dataProps
function.
It will
data-
andSpread the return value of dataProps
on the element you would like the data attributes applied to.
import dataProps from 'react-data-props';
const Thing = ({ text, ...restProps }) => (
<div {...dataProps(restProps)}>{text}</div>
);