Release 0.3 External Project blog

For my external project, I worked in the open source Binari project.


I found that useEffect function should be in it's own custom hook with the implementation for getting contributors to make code more readable and possibly reusable. I implemented a custom hook, useGetContributors to extract implementation related to get contributors into the custom hook. Issue 25

I created my own fork. Then I cloned from my fork. I created a new branch using the command 

git checkout -b issue-25

Then I ran the command 

npm i

to install the required dependancies into my project repo. Then I ran 

npm run start

to test the project. I tested to make sure the project was getting all the contributors on the about page.

I created a custom hook and extracted implementation related to get contributors into the custom hook.

The custom hook receives a URL as a parameter and fetches the data with url and reqOptions.

Then useEffect will executed everytime when the URL change.

The fetch data async arrow function creates a new instance of Headers

and appends the status and token to the new instance.

A new object reqOptions is created with the method, headers and redirect.

The url and reqOptions object send to fetch to get contributors response.

The response gets converted from JSON to data object.

The useGetContributors custom hook return the contributers data.

Then I ran

npm run start

to test the project. Then I added the changes in git. Then commited the changes on git.

Then I pushed the changes. I created a new PR. 


I learned how to create custom hooks,

and extracting a function into a custom hook to make code more organized.

issue: https://github.com/BrandonArmand/Binari/issues/25

PR: https://github.com/BrandonArmand/Binari/pull/75




Comments

Popular posts from this blog

Lab 8 Blog

Octoberfest Week 2 Blog

Lab 9 Blog