1.0.6 • Published 4 years ago

@thira/react-mugfetcher v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

N|Solid

Build man Build man Build man

React Mug Fetcher

React API fetch data without asynchronous or hooks

Installation

NPM
npm i @thira/react-mugfetcher
YARN
yarn add @thira/react-mugfetcher

Implement React Mug Fetcher

First import the library

import { useFetcher } from "@thira/react-mugfetcher";
Implement a simple fetch request
const { data, loading, error, length } = useFetcher("https://jsonplaceholder.typicode.com/comments?postId=1"); 
Simple example code
import { useFetcher } from "@thira/react-mugfetcher";

function App() {
  const { data, loading, error, length } = useFetcher("https://jsonplaceholder.typicode.com/comments?postId=1"); 

  if(loading){
    return <p> Loading... </p>
  }

  return (
    <div className="App">
      <ul>
        {data.map(item => (
          <li key={item.id}>{item.name}</li>
        ))}
      </ul>
      <p>Total items = {length}</p>
    </div>
  );
}

export default App;

Thank you for using React Mug Fetcher!

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago