Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. const Profile = ({ username, age }) => (
  2. <div>
  3. <div>Username: {username}</div>
  4. <div>Age; {age}</div>
  5. </div>
  6. );
  7. Profile.propTypes = {
  8. username: string,
  9. age: number
  10. };
  11.  
  12. // Usage - wrapping the component with the function
  13. const withFlattenUser = flattenProp('user');
  14. const ProfileWithFlattenUser = withFlattenUser(Profile);
  15.  
  16. // OR
  17. const ProfileWithFlattenUser = flattenProp('user')(Profile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement