twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Notes flash after note update/creation

Open Bonapara opened this issue 1 year ago • 3 comments

Description

Notes are flashing when creating or updating a note

https://github.com/twentyhq/twenty/assets/19412894/76d90c79-d913-42ea-80b1-e9cd479bda48

Where

Twenty (demo) workspace

How to reproduce

Go to a record page with existing notes and try to create a new one.

Bonapara avatar May 16 '24 14:05 Bonapara

Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :). To resolve the issue of notes flashing after update/creation, follow these steps:

  1. Investigate useNotes Hook:

    • File: src/hooks/useNotes.js
    • Check the logic for fetching and updating notes. Ensure that state updates are batched correctly to prevent unnecessary re-renders.
  2. Review Notes Component:

    • File: src/components/Notes.js
    • Look for the rendering logic and see if there are any forced re-renders or state changes that could cause the flashing.
  3. Optimize State Management:

    • Ensure that the state is updated in a way that minimizes re-renders. Consider using React.memo or useCallback to optimize the component rendering.
  4. Example Code Fix:

    // src/hooks/useNotes.js
    const updateNote = async (note) => {
      // Existing update logic
      // Add batching or debounce logic here if necessary
    };
    
    // src/components/Notes.js
    const Notes = React.memo(({ notes }) => {
      // Existing rendering logic
      // Ensure that the component only re-renders when necessary
    });
    

References

greptile-apps[bot] avatar May 16 '24 14:05 greptile-apps[bot]

Hello, @Bonapara ! Please check PR #5469 :)

H0onnn avatar May 21 '24 08:05 H0onnn

Hi @H0onnn, I'm not technical myself, but the tech team will look into it soon. Thanks!

Bonapara avatar May 21 '24 09:05 Bonapara

Can't reproduce on main closing for now, don't hesitate to re-open.

lucasbordeau avatar May 30 '24 10:05 lucasbordeau