Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { useState } from 'react';
- const UseHook = ({ children, hook, args }) => children(hook(...args));
- <UseHook hook={ useState } args={ [0] }>
- { ({ count, setCount }) => (
- <button type="button" onClick={ () => setCount(count + 1) }>I have been clicked { count } times</button>
- ) }
- </UseHook>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement