react-with-hooks
v1.1.6
Published
react hooks polyfill
Downloads
2,939
Readme
react-with-hooks
Ponyfill for the proposed React Hooks API.
Works on RN!
Install
$ npm i react-with-hooks --save
Example
import withHooks, { useState, useEffect } from '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>
);
});
API Reference
- Basic Hooks
- Additional Hooks
- useReducer
- useCallback
- useMemo
- useRef
- useImperativeMethod
- ⚠️ useMutationEffect - works same as
useEffect
- ⚠️ useLayoutEffect - works same as
useEffect