0.5.2 • Published 5 years ago

usehook v0.5.2

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

useHook

dependencies size (gzip size module formats: umd, cjs, and es

npm package MIT License React PRs welcome

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

0.5.2

5 years ago

0.5.0

5 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago