Created
September 26, 2020 09:35
-
-
Save samipshah100/15a946573e46ce5f06c5a4fc873453fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from 'react' | |
import { useFetchEffect } from '../../hooks/useFetchEffect' | |
const DemoComponent = () => { | |
const url = 'https://jsonplaceholder.typicode.com/posts' // sample api | |
const data = useFetchEffect(url) | |
// (optional) you can add your own useEffects e.g. | |
useEffect(() => { | |
window.addEventListener('keydown', handleUserKeyPress) | |
return () => { | |
window.removeEventListener('keydown', handleUserKeyPress) | |
} | |
}, [handleUserKeyPress]) | |
return <div className="DemoComponent">{data.map(<div>{data.name}</div>)}</div> | |
} | |
export default DemoComponent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment