A custom React hook that provides a random quote from QuoteGarden
npm install --save @marekdano/use-quote
OR
yarn add @marekdano/use-quote
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
}
MIT © marekdano
This hook is created using create-react-hook.