icssc / zotnfound-frontend

ZotNFound.com
2 stars 1 forks source link

Item description typing is slow #11

Closed tyleryy closed 7 months ago

tyleryy commented 9 months ago

In the list item modal, when the user types a description of the item, it is slow and the typing lags. This may because the onChange callback for the Chakra textbox is called for every key input in the textbox, overloading the component's re-rendering.

May need to make component uncontrolled and use a ref to get the text state in only when needed (when the next button is pressed)

NwinNwin commented 8 months ago

How to find the bug:

Click on “List item” → type on item description or item name The text is laggy and slow when rendering

image

Why is this:

In CreateModal, we use onChange to update item name + item description. This make it so that every time user types, it do a rerender → cause the program to be slow

How to fix:

Replace onChange with useRef (https://react.dev/reference/react/useRef)