Yes! I solved this problem! It was because of the useEffect(), but it wasn't because it was being used twice.
The problem was because I didn't add an empty array to my useEffect() function so that it would have only run once:
const saveLocalTodos = () => {
localStorage.setItem("todos", JSON.stringify(todos));
};
const getLocalTodo = () => {
if (localStorage.getItem("todos") === null) {
localStorage.setItem("todos", JSON.stringify([]));
} else {
let todoLocal = JSON.parse(localStorage.getItem("todos"));
setTodos(todoLocal);
}
};
useEffect(() => {
getLocalTodo();
}, []);
But thanks @SandeepMewara for your help! 😃