Thank you for your interest in contributing to Rehook! I appreciate your support and look forward to your contributions. This guide will help you understand the directory structure and provide detailed instructions on how to add a new hook to Rehook.
Once done, open a pull request from your forked repo to the main repo here.
-
Fork this repository
Click here to fork the repository. -
Clone your forked repository to your local machine
git clone https://github.com/<YOUR_USERNAME>/rehook.git
-
Navigate to the project directory
cd rehook
-
Create a new branch for your changes
git checkout -b my-new-branch
-
Install dependencies
npm install
-
Run the project
npm run dev
To add a new hook to Rehook, you will need to modify several files. Follow these steps:
File: src/hooks/use-example.ts
Create the hook file.
const useExample = () => {
// Your code here
}
File: src/hooks/__tests__/use-example.spec.ts
describe('useExample', () => {
// Your test cases here
})
Go to rehook-wesbite repository and clone it.
File: pages/hooks/use-example.mdx
# useExample
<h3 className="mt-4 text-xl font-normal text-gray-400">Description.</h3>
## Add hook
Create a file `use-example.ts` and copy & paste the code from [useExample](/hooks/use-example#hook).
## Usage
function App() {
const {example} = useExample()
}
export default App
### Hook
const Example = ()=>{
// Your hook code here
}
export default Example
## API
{' '}
<h3 className="text-xl font-medium mt-6">Parameters</h3>
| Parameter | Type | Description |
| --------- | ------ | ------------ |
| `name` | `type` | Description. |
| |
{' '}
<h3 className="text-xl font-medium mt-6">Returns</h3>
| Name | Type | Description |
| ------ | ------ | ------------ |
| `name` | `type` | Description. |
File: pages/hooks/_meta.json
"use-example":"useExample"
File: theme.config.tsx
sidebar: {
titleComponent({ title, type }) {
return (
<div className="flex items-center justify-between relative w-full">
<div>{title}</div>
{(title === "useExample"
) && (
<Badge className=" absolute -right-[0.5em] bg-transparent border-lime-400 text-lime-500 px-[0.5em] hover:bg-transparent">
New
</Badge>
)}
{title === "useFetch" && (
<Badge className=" absolute -right-[0.5em] bg-transparent border-pink-500 text-pink-500 px-[0.5em] hover:bg-transparent">
Updated
</Badge>
)}
</div>
);
},
},
For any help or questions, please open a new GitHub issue and we will get back to you :)