Last active
June 7, 2021 14:51
-
-
Save t1ger-0527/f839a3f59bdcad3300e3e4865bb09027 to your computer and use it in GitHub Desktop.
pass-dataset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import mapKeys from 'lodash/mapKeys' | |
| const toKebabDataSet = (dataSet = {}) => { | |
| return mapKeys( | |
| dataSet, | |
| (_, key) => 'data-' + key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase() | |
| ) | |
| } | |
| export default (props) => { | |
| return ( | |
| <div {...toKebabDataSet(props.dataSet)} /> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment