1.2.2 • Published 2 years ago

@24hr/react-hooks v1.2.2

Weekly downloads
7
License
MIT
Repository
github
Last release
2 years ago

@24hr/react-hooks

All Contributors

Build

React hooks library

Documentation

useBeforeMount

A hook that runs before mount and is suitable for SSR.

useBeforeMount(() =>
    console.log('Runs only once before component mounts. Works on the server!')
)

useLocalStorage

A hook that syncs state with localstorage

/**
 * @typedef Options
 * @property {boolean} [clearOnUnmount] - Whether or not to clear the localstorage value on unmount.
 */

/**
 * A hook that syncs the state with a property in the localstorage.
 * @param {string} defaultVal - The initial value
 * @param {string} key - Mandatory key to use to store the data in localstorage.
 * @param {Options} options - Options object
 * @return {[any, function, function]} - Return the current state, a set state function and a function to clear the storage.
 */
const [state, setState, clear] = useLocalStorage('default value', 'key', { clearOnUnmount: false });

Want to contribute?

It's easy to contribute!

  1. Clone the repo and create a new branch from master.

  2. Make your changes.

  3. Run ./bump.sh and choose if your changes are major, minor och patch.

  4. Commit and push.

  5. Make a merge request to master. The CI pipeline will publish your new version to NPM!

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

1.2.2

2 years ago

1.2.1

3 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago