mirror of
https://github.com/kremalicious/portfolio.git
synced 2025-02-14 21:10: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 giphyClient = new GiphyFetch('LfXRwufRyt6PK414G2kKJBv3L8NdnxyR')
|
||||||
const tag = 'cat'
|
const tag = 'cat'
|
||||||
|
|
||||||
export default function NotFound() {
|
async function getRandomGif() {
|
||||||
const [gif, setGif] = useState('')
|
|
||||||
|
|
||||||
async function getRandomGif() {
|
|
||||||
try {
|
try {
|
||||||
let response = await giphyClient.random({ tag })
|
let response = await giphyClient.random({ tag })
|
||||||
const gif = response.data.images.original.mp4
|
const gif = response.data.images.original.mp4
|
||||||
setGif(gif)
|
return gif
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.message)
|
console.error(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function NotFound() {
|
||||||
|
const [gif, setGif] = useState('')
|
||||||
|
|
||||||
async function handleClick(e) {
|
async function handleClick(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@ -29,7 +29,11 @@ export default function NotFound() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getRandomGif()
|
async function init() {
|
||||||
|
const gif = await getRandomGif()
|
||||||
|
setGif(gif)
|
||||||
|
}
|
||||||
|
init()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user