@marekdano/use-quote

1.0.0 • Public • Published

@marekdano/use-quote

A custom React hook that provides a random quote from QuoteGarden

NPM JavaScript Style Guide

Install

npm install --save @marekdano/use-quote

OR

yarn add @marekdano/use-quote

Usage

import React, { Component } from 'react'

import { useQuote } from '@marekdano/use-quote'

const Example = () => {
  const { quote, isLoading, isError } = useQuote()
  
  if (isLoading) return <p>Loading...</p>

  if (quote) {
    return (
      <>
        <p>{quote.text}</p>
        <p><i>{quote.author}</i></p>
      </>
    )
  }

  if (isError) return <p>Difficulty displaying a quote at the moment.</p>

  return null
}

License

MIT © marekdano


This hook is created using create-react-hook.

Readme

Keywords

none

Package Sidebar

Install

npm i @marekdano/use-quote

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

126 kB

Total Files

21

Last publish

Collaborators

  • marekdano