Created
July 2, 2018 03:36
-
-
Save ruucm-working/878112b8d587a223e44e4ee3b8aba7bc to your computer and use it in GitHub Desktop.
Make Unique Id by props in React
This file contains 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
/** | |
* | |
* 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