Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. import React, { useState } from 'react';
  2.  
  3. const UseHook = ({ children, hook, args }) => children(hook(...args));
  4.  
  5. <UseHook hook={ useState } args={ [0] }>
  6. { ({ count, setCount }) => (
  7. <button type="button" onClick={ () => setCount(count + 1) }>I have been clicked { count } times</button>
  8. ) }
  9. </UseHook>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement