Skip to content

ReactJs application that demonstrates useEffect and useState hooks in a function-based component.

License

Notifications You must be signed in to change notification settings

bobmacneal/simple-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-hooks

This is a sample ReactJs application. It demonstrates one way to use React's built-in hooks such as useEffect and useState, as well as shows an an example of a custom hook in function-based components. Each successful request to the JSONPlaceholder API displays a list of sample data items corresponding to the tab clicked by the user.


users UsersList component

Material-UI React components are used for design and functional simplicity.

Custom Hook

A React custom hook useAxiosGetItems is demonstrated. The custom hook uses axios to request items from the JSONPlaceholder API. useAxiosGetItems is referenced by a service layer function called getResources. The custom hook returns list items, a loading boolean for a progress indicator, and any HTTP errors that occur during the request: return {listItems, loading, error}.

Setup

  1. Clone the repository: git clone https://github.com/bobmacneal/simple-hooks.git
  2. Install Yarn for package management.
  3. Install node dependencies using yarn: yarn

Run

  • Run app locally: yarn start

Hat Tips

About

ReactJs application that demonstrates useEffect and useState hooks in a function-based component.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published