Skip to content

It is a small project showing how react-hooks can be used

License

Notifications You must be signed in to change notification settings

stLoiz/react-hooks-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Decription

It is a small demo project to show how react hooks are working and how they can be implemented.
You can checkout the project here

The basic functionalities are:

  • the user can store fruits and the amount of the fruits in database,
  • the user can remove the fruits from database
  • the user can search and find the fruits that are stored in database

The hooks that the project is using are:

  • useState()
  • useEffect()
  • useMemo()
  • useReducer()
  • useCallBack()
  • useContext()

Also a custom hook is created which is responsible to handle the http requests and have the useEffect() to handle the response of the requests.

A good explanantion of how the hooks are implemented each time is described in the commits.

To run the project

  1. Clone the project

  2. In the project directory:

  • run npm install
  1. Create the database I used firebase to create a dummy database. You can do the same as it is really quick:

Click on this link and create a project. Then configure the database rules under the database tab by adding the following json:

{ "rules": { ".read": true, ".write": true, "ingredients": { ".indexOn" : ["title"] } } }

  1. Conifigure env.

Create a file .env to the root of the project directory and add this:

REACT_APP_FIREBASE_URL='your/firebase/url'

Get your firebase database url from your firebase project that you created, it is under the database tab.

  1. In your project directory run yarn start

About

It is a small project showing how react-hooks can be used

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published