mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-23 01:29:41 +01:00
refactor
This commit is contained in:
parent
2569fc6218
commit
820baca23f
@ -10,18 +10,18 @@ import styles from './404.module.css'
|
||||
const giphyClient = new GiphyFetch('LfXRwufRyt6PK414G2kKJBv3L8NdnxyR')
|
||||
const tag = 'cat'
|
||||
|
||||
export default function NotFound() {
|
||||
const [gif, setGif] = useState('')
|
||||
|
||||
async function getRandomGif() {
|
||||
async function getRandomGif() {
|
||||
try {
|
||||
let response = await giphyClient.random({ tag })
|
||||
const gif = response.data.images.original.mp4
|
||||
setGif(gif)
|
||||
return gif
|
||||
} catch (error) {
|
||||
console.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function NotFound() {
|
||||
const [gif, setGif] = useState('')
|
||||
|
||||
async function handleClick(e) {
|
||||
e.preventDefault()
|
||||
@ -29,7 +29,11 @@ export default function NotFound() {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getRandomGif()
|
||||
async function init() {
|
||||
const gif = await getRandomGif()
|
||||
setGif(gif)
|
||||
}
|
||||
init()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user