Hi everyone,
my thoughts won’t leave me! Maybe I should call a psychiatrist!!
The delete function works ok, when I click on the X they are deleted, but they do not disappear after 15 secs.
import React, { useEffect } from 'react';
export function Thought(props) {
const { thought, removeThought } = props;
useEffect(()=>{
const timeRemaining = thought.expiresAt - Date.now();
const timer = setTimeout(()=>{
alert("Time passed");
},timeRemaining)
return ()=> {clearTimeout(timer)}
},[thought]);
const handleRemoveClick = () => {
removeThought(thought.id);
};
I tried also setting
const timeRemaining = 1000;
but it does not work either…