I have some Javascript code that will be run when a component has completed loading:
function HelloThere() {
React.useEffect(() => {
setTimeout(() => {
// code to make a server call to write data to DB
}, 60 * 1000);
}, []);
return <h1>Hello there</h1>;
}
My question is, if the code in the useEffect is hit (component is loaded) but the user closes the tab (or refresh browser) before 60 seconds timeout, would the code still be running in the background and write data to DB? Thanks for the help!