0.0.2 • Published 5 years ago

@sgovil/react-custom-hooks v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

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.