This code runs when name is changed (as it should) but it also runs when the component first loads. How can I have it run only on subsequent changes to name and not the first time the default value is set?
const [name, setName] = useState('');
useEffect(() => {
alert('Hi ' + name);
}, [name]);