Skip to content

Instantly share code, notes, and snippets.

@samipshah100
Last active September 26, 2020 19:34
Show Gist options
  • Save samipshah100/5efbcae7ee5fa75fae7085d9c2fce1bc to your computer and use it in GitHub Desktop.
Save samipshah100/5efbcae7ee5fa75fae7085d9c2fce1bc to your computer and use it in GitHub Desktop.
import React from 'react'
import { useFetchEffect } from '../../hooks/useFetchEffect'
const AnotherComponent = () => {
const url = 'https://anotherAPIEndpoint.com/route' // sample api
const responseData = useFetchEffect(url)
const {isLoading, data} = responseData // destructure out the data from the hook
if(isLoading) // Show a spinner or loading animation
return <p>Loading...</p>
return <div className="AnotherComponent">{data.map(<div>{data.name}</div>)}</div>
}
export default AnotherComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment