-
-
Notifications
You must be signed in to change notification settings - Fork 291
Custom Value Editor Re-renders Entirely on Dropdown Option Change #889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Couple of things here: For one, version 7 introduced a ton of performance improvements mainly related to memoization, so upgrading to the latest (currently v8.5.0) may resolve any perf issues you're encountering with v6.5.5. Secondly, you say "The dropdown should update its value without re-rendering the entire custom value editor." I may be wrong, but I'm pretty sure that can only be the case with an uncontrolled component (and maybe not even then, at least it's not guaranteed). All sub-components (custom or not) are controlled components within But I'm curious why it matters. Are you seeing issues due to too many re-renders of the value editor specifically? Now that I'm typing this out, I'm getting the feeling you're talking about re-renders of the entire query builder component and not just the value editor. If that's the case, then upgrading to the latest version should resolve the problem. |
Hi @jakeboone02, Re-renders occur in the custom value editor due to API calls with I understand that Thanks. |
Ok now I'm curious about your actual code and the workaround you implemented. Any chance you could elaborate? |
Hi @jakeboone02, sorry for the delayed response.
Thanks |
React Query Builder version
6.5.5
Platform
Chrome on macOS 15.4.1
Description
Hi,
When using a custom value editor with a select dropdown in the React Query Builder, the entire custom value editor re-renders whenever the props.handleOnChange function is triggered by selecting an option in the dropdown. This behaviour is causing performance issues and unnecessary API calls.
Reproduction
Steps to reproduce:
Expected behavior
The dropdown should update its value without re-rendering the entire custom value editor.
The parent component should not trigger unnecessary API calls or state updates unless the value has genuinely changed.
Additional information
The issue is likely caused by the props.handleOnChange function triggering a state update in the parent component, which propagates back to the custom value editor.
The dropdown options are dynamically generated, and the value is passed as a prop to the dropdown.
Sample code:
The text was updated successfully, but these errors were encountered: