0.0.4 • Published 6 years ago
usefetch-caching v0.0.4
⚛️ 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
- Github: @LJeremy
Show your support
Give a ⭐️ if this project helped you!