0.0.4 • Published 6 years ago

usefetch-caching v0.0.4

Weekly downloads
15
License
MIT
Repository
github
Last release
6 years ago

⚛️ 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;

Author

👤 Lars

Show your support

Give a ⭐️ if this project helped you!

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago