1.0.0 • Published 5 years ago

@anacr/react-use-sw-quote v1.0.0

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

@anacr/react-use-sw-quote

a custom React hook for getting a random Star Wars quote

NPM JavaScript Style Guide

Install

npm install --save @anacr/react-use-sw-quote

Usage

import React from "react";
import { useStarWarsQuote } from "@jsjoeio/react-use-sw-quote";

const App = () => {
  const { quote, loading } = useStarWarsQuote("");
  // Quote returns a random quote as a string
  // loading returns a boolean

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

  if (quote) {
    return <div>{quote}</div>;
  }

  return null;
};
export default App;

License

MIT © anacr


This hook is created using create-react-hook.