I am using react to fetch data and show it in my app . If I am loading , I display the message : "Loading ..." .
What I want is to use setTimeout() to show the loading message for a few more seconds than it should be . However I do not know how to write this in react .
My code :
export default function JobList() {
const {loading ,error , jobs} = useFetch();
return (
<div>
{loading && <p> Loading </p>} //HOW DO I USE SETTIMEOUT ON THIS <P> ELEMENT ?
{jobs && jobs.map(j=>return <p> {j.title} </p>)}
</div>
);
}