@sgovil/react-custom-hooks

0.0.2 • Public • Published

react-custom-hooks

Useful list of custom React hooks

NPM JavaScript Style Guide demo site

Install

npm install --save @sgovil/react-custom-hooks

Usage

import React from "react";
import useFetch from "@sgovil/react-custom-hooks";

export default function App() {
  const [response, error, loading] = useFetch(
    "https://jsonplaceholder.typicode.com/todos"
  );
  return (
    <div>
      <h1>React Custom Hooks</h1>

      {loading && <div>Loading...</div>}
      {!loading && error && <div>{error.message}</div>}
      {!loading && !error && response && (
        <div>
          <h2>Fetch Complete</h2>
          <pre>{JSON.stringify(response, undefined, 2)}</pre>
        </div>
      )}
    </div>
  );
}

License

MIT © sumgwork


This hook is created using create-react-hook.

Readme

Keywords

none

Package Sidebar

Install

npm i @sgovil/react-custom-hooks

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

23.7 kB

Total Files

6

Last publish

Collaborators

  • sgovil