`GlobalSearch` renders unnecessarily when not empty
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
-
Start NUSMods locally (you can't use nusmods.com as we need a development copy of React).
-
Type something into global search.
-
Begin recording a profile in the React Profiler (Chrome version here).
-
Do something unrelated to global search, e.g. go to http://localhost:8080/contribute and click the Show More button in the Map the School section.
-
Stop the recording.
-
Notice
GlobalSearch rendered:
-
Reload the page, and record another profile without entering anything into global search. Notice that
GlobalSearchdid not render and that there were fewer renders:
Expected behavior
GlobalSearch should not render unnecessarily.
Additional context
It may be easier to fix this after #3039 is merged, so that we can use the React scheduling profiler to see if there are any unexpected state updates.