Skip to content

⚛️ React Hook for Fetching Data & caching it in Localstorage

License

Notifications You must be signed in to change notification settings

LJeremy/useFetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

⚛️ useFetch 👋

Version npm

⚛️ React Hook for Fetching Data & caching it in Localstorage

Install

npm install usefetch-caching

Usage

Firstly, Import the package:

import { useFetch } from 'usefetch-caching';

Fetch an URL and store the response:

const response = useFetch(
  `https://jsonplaceholder.typicode.com/todos`,
  'todos'
);

Example use case:

function Todos()  {

const response = useFetch(
  `https://jsonplaceholder.typicode.com/todos`,
  "todos"
);

return response != null  ? (
  response.map((todo, key)  => (
    <>
      <h3>{todo.title}</h3>
      <span>{todo.completed  ?  "✔️"  :  "❌"}</span>
    </>
  ))
  ) : (
    <>
      <span>No todo's</span>
    </>
  );
}

export default Todos;

Edit restless-leaf-b32hd

Author

👤 Lars

Show your support

Give a ⭐️ if this project helped you!

About

⚛️ React Hook for Fetching Data & caching it in Localstorage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published