@sgovil/react-custom-hooks

Useful collection of custom React hooks

Usage no npm install needed!

<script type="module">
  import sgovilReactCustomHooks from 'https://cdn.skypack.dev/@sgovil/react-custom-hooks';
</script>

README

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.