Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-8697

Avoid recreating ref contents in useRef

    • Type: Icon: Task Task
    • Resolution: Won't Do
    • Priority: Icon: Minor - P4 Minor - P4
    • No version
    • Affects Version/s: None
    • Component/s: React, Tech debt
    • None
    • 2
    • Iteration Regolith
    • Not Needed
    • Developer Tools

      https://react.dev/reference/react/useRef#avoiding-recreating-the-ref-contents
      const someRef = useRef(new Something());

      This will re-create a new object on each render even though it's not used, only the initial value is used. Looks like we have a couple occurrences of this in Compass (and at the CompassWeb entrypoint. Can be a performance hit if the constructor or object creation is expensive or doing things.

      This ticket involves updating those occurrences to follow the recommended pattern in the linked doc. 
      Maybe  a lint for `useRef(new ...` that errors and links that page could be useful.

            Assignee:
            rhys.howell@mongodb.com Rhys Howell
            Reporter:
            rhys.howell@mongodb.com Rhys Howell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: