Django-React-NotesApp icon indicating copy to clipboard operation
Django-React-NotesApp copied to clipboard

List of notes is not always updated after updating or creating a note

Open CarloDiPalma opened this issue 2 years ago • 1 comments

Sometimes(~50%) it need hard page refresh or step back to NotePage and come back to list of notes again

CarloDiPalma avatar Nov 29 '22 08:11 CarloDiPalma

I added async and await to handleSubmit in NotePage.js and and it looks like it fixed the problem.

let handleSubmit = async () => {
        console.log('NOTE:', note)
        if (noteId !== 'new' && note.body === '') {
            deleteNote().then(() => {console.log('deleteNote')})
        } else if (noteId !== 'new') {
            await updateNote().then(() => {console.log('updateNote')})
        } else if (noteId === 'new' && note.body !== null) {
            await createNote().then(() => {console.log('createNote')})
        }
        history.push('/')
    }

CarloDiPalma avatar Dec 03 '22 10:12 CarloDiPalma