-
Notifications
You must be signed in to change notification settings - Fork 658
Description
Describe the bug
While working on the internship assessment, I noticed that updating one component’s state (like a checkbox) causes all components to re-render, including heavy ones like tables. This leads to unnecessary performance hits and noticeable UI lag for large components.
The should_render function in utils.py (called in render_tracking.py) is being called twice per component, and the hash-based comparison is not working as expected.
Specifically:
- The code stores a hash of the old component data.
- But when comparing, it does not hash the new data — instead, it compares raw cleaned values, which causes
has_changedto returnTrueeven when values are the same. - Also, after each update, the
state_cachedoes not retain updated state, which breaks comparison in the next render.
To Reproduce
Steps to reproduce the behavior:
- Create a
hello.pyfile with a table and a checkbox that displays a text. - Go to
utils.pyand find thehas_changedfunction. - Log
old_cleanandnew_clean. - Observe the output after toggling the checkbox.
Expected behavior
has_changedshould be called once per component, not twice.- If a component hasn’t changed,
old_cleanandnew_cleanshould be equal. should_rendershould returnFalseif values are identical.
Screenshots
Below, I modified the code to compare the hash of both old and new values, exposing the issue of should_render always returning True:
Environment:
- OS: macOS
- Browser: Chrome
- Version: 137
Additional context
In render_tracking.py, I attempted the following change to avoid double invocation of should_render:
from this
component['shouldRender'] = service.should_render(component_id, component)
# Append component only if changed
if service.should_render(component_id, component):to this
component['shouldRender'] = service.should_render(component_id, component)
# Append component only if changed
if component['shouldRender']:still the issue is there
