Skip to content

Instantly share code, notes, and snippets.

@ruucm-working
Created July 2, 2018 03:36
Show Gist options
  • Save ruucm-working/878112b8d587a223e44e4ee3b8aba7bc to your computer and use it in GitHub Desktop.
Save ruucm-working/878112b8d587a223e44e4ee3b8aba7bc to your computer and use it in GitHub Desktop.
Make Unique Id by props in React
/**
*
* Frame
*
*/
import React from 'react'
import { compose, mapProps } from 'recompose'
import { uniqueId } from 'lodash'
const Frame = props => {
return (
<div style={props.style}>
<h1>Component Unique Id : {props.frame_id}</h1>
</div>
)
}
// Component enhancer
const enhance = compose(
mapProps(({ children, ...rest }) => {
return {
frame_id: uniqueId('frame_'),
children: children,
...rest,
}
})
)
export default enhance(Frame)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment