The purpose of this guide is to help you to create your own UI Hooks.
- Node: any 10.x version.
npminstalled.- Fork react-ui-hooks repo (for any contributions).
- Get the project on your local machine, following the example:
git clone https://github.com/YOUR-GITHUB-USERNAME/react-ui-hooks.git.
- First things first, if you want to create a new hook, you have to give it a name that starts with
useand then the name of the hook, such as useModal, useSlider, etc. - If you try to create a hook without this pattern, you'll get an error.
The npm run generate:hook command create 3 files:
- A hook file useExample.js
- The tests file useExample.test.js
- The documentation file useExample.md
The hook and its tests files must be updated manually, the documentation file can be updated all at once by using the npm run generate:docs command.
- Open your shell and run the command:
npm run generate:hook useExampleuseExample.js on src/hooks/
useExample.test.js on src/tests/hooks
useExample.md on docs/
If you've created your hook manually you can generate its unit test file with the command:
npm run generate:test useExample.jsYou can get the doc file of your hook created automaticaly as well!
npm run generate:docs useExample.jsAs you update the hooks and tests frequently there's a need to update the documentation, so you can do it for all of the hooks with:
npm run generate:docsThis command scans your hooks and its tests to generate the documentation.