@marekdano/use-quote
v1.0.0
Published
a custom React hook that provides a random quote from QuoteGarden
Downloads
4
Readme
@marekdano/use-quote
A custom React hook that provides a random quote from QuoteGarden
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.