Ошибка при добавлении объекта в массив

Ошибки:

Unchecked runtime.lastError: The message port closed before a response was received.

Too many re-renders. React limits the number of renders to prevent an infinite loop

Функция по добавлению объекта в localStorage:

function getData(event: any) {
        event.preventDefault();
        const now = `${new Date().getHours()}:${new Date().getMinutes()}`
        const notes = JSON.parse(localStorage.getItem('notes') || '[]');
        const note = {
            title: titleNote,
            text: textNote,
            time: now
        };

        notes.push(note);
        localStorage.setItem('notes', JSON.stringify(notes));
        dispatch(setNotesAction(notes));
}

Также добавляю в App.tsx, чтобы при перезагрузке страницы все объекты визуально сохранялись:

const dispatch = useDispatch();
  const notesStorage = JSON.parse(localStorage.getItem('notes') || '[]');
  dispatch(setNotesAction(notesStorage));
  const notesRedux = useSelector((state: any) => state.notes.items);


Ответы (0 шт):