react-with-hooks-odgn

Ponyfill for the proposed React Hooks API.

Usage no npm install needed!

<script type="module">
  import reactWithHooksOdgn from 'https://cdn.skypack.dev/react-with-hooks-odgn';
</script>

README

react-with-hooks

Ponyfill for the proposed React Hooks API.

Install

$ npm i odgn-react-with-hooks --save

Example

import withHooks, { useState, useEffect } from 'odgn-react-with-hooks';

const Counter = withHooks(() => {
  const [ count, setCount ] = useState(0);
  useEffect(() => {
    document.title = "count is " + count;
  })
  return (
    <div>
       {count}
       <button onClick={() => setCount(count + 1)}>+</button>
       <button onClick={() => setCount(count + 1)}>-</button>
    </div>
  );
});

Live Demo

API Reference

License

MIT