3.4 KiB
Contributing
Thanks for being willing to contribute 🙌 If you contribute to this project, you agree to release your work under the license of this project.
Working on your first Pull Request? You can learn how from this First Contributions guide.
Project setup
- Fork and clone the repo
- Run
yarn installto install dependencies - Create a branch for your PR with
git checkout -b pr/your-branch-name
Tip: Keep your
masterbranch pointing at the original repository and make pull requests from branches on your fork. To do this, run:git remote add upstream https://github.com/streamich/react-use.git git fetch upstream git branch --set-upstream-to=upstream/master masterThis will add the original repository as a "remote" called "upstream," Then fetch the git information from that remote, then set your local
masterbranch to use the upstream master branch whenever you rungit pull. Then you can make all of your pull request branches based on thismasterbranch. Whenever you want to update your version ofmaster, do a regulargit pull.
Development
This library is a collection of React hooks so a proposal for a new hook will need to utilize the React Hooks API internally to be taken into consideration.
Creating a new hook
- Create
src/useYourHookName.tsandstories/useYourHookName.story.tsx, runyarn startto start the storybook development server and start coding your hook - Create
tests/useYourHookName.test.ts, runyarn test:watchto start the test runner in watch mode and start writing tests for your hook - Create
docs/useYourHookName.mdand create documentation for your hook - Export your hook from
src/index.tsand add your hook toREADME.md
You can also write your tests first if you prefer test-driven development.
Updating an existing hook
- Run
yarn startto start the storybook development server and start applying changes - Update tests according to your changes using
yarn test:watch - Update documentation according to your changes
Committing and Pushing changes
Commit messages
This repo uses semantic-release and conventional commit messages so prefix your commits with fix: or feat: if you want your changes to appear in release notes.
Git hooks
There are git hooks set up with this project that are automatically enabled
when you install dependencies. These hooks automatically test and validate your code when creating commits. They're really handy but can be temporarily disabled by adding a --no-verify flag to your commit command. This is useful when you want to commit and push to get feedback on uncompleted code.
Help needed
Please have a look at the open issues and respond to questions, bug reports and feature requests. Thanks!
We're also looking to improve the code coverage on this project. To easily know what hooks need tests run yarn test:coverage to generate a code coverage report. You can see the report in your terminal or open coverage/lcov-report/index.html to see the HTML report.