@jsjoeio/react-use-chuck-norris
v1.0.0
Published
A custom React Hook which gives you a Chuck Norris joke
Downloads
1
Readme
@jsjoeio/react-use-chuck-norris
A custom React Hook which gives you a Chuck Norris joke
Install
npm install --save @jsjoeio/react-use-chuck-norris
Usage
import React, { Component } from 'react'
import { useChuckNorris } from '@jsjoeio/react-use-chuck-norris'
const Example = () => {
const { data, loading, error} = useChuckNorris()
if (loading) return <p>Loading...</p>
if (error) return <p>Oh no! There was an error: {error}</p>
if (data)
// Data returns a Chuck Norris joke as a string
// Each joke is random
return (
<p>{data}</p>
)
}
License
MIT © jsjoeio
This hook is created using create-react-hook.