usehook
v0.5.2
Published
useHook React component
Downloads
22
Readme
useHook
Just use the hooks. This library aims to provide a possibility to use fancy React hooks in yur plain old components. Yes, even in classes. It does so, by providing a render prop
which you can pass your hook to.
Usage
See example
folder. Or enjoy a codesandbox!
import React, { useState } from 'react';
import UseHook from 'usehook';
class Hooked extends React.Component {
render() {
return (
<UseHook hook={[useState, 0]}>
{([number, setNumber]) => (
<div>
<span>Number: {number}</span>
<button onClick={() => setNumber(number + 1)}>+1</button>
</div>
)}
</UseHook>
);
}
Contributors
Thanks goes to these people (emoji key):
| Christoph Benjamin Weber💻 📖 💡 | | :---: |
This project follows the all-contributors specification. Contributions of any kind welcome!
LICENSE
MIT