Performance issue when editing large queries #905
-
|
Hi! I'm using react-querybuilder to build dynamic rule sets which can be complex and large. I've noticed that once there are more than 20 rule/rule groups, typing into an input field inside a rule starts to feel noticeably laggy — there's a delay between each keystroke and the value updating. This issue also seems to occur on the demo page — you can reproduce it by creating several rule groups, as shown in this video: Screen.Recording.2025-06-20.at.18.43.45.movMy setup is almost the same as the one used in the demo, and to the best of my knowledge, I’ve tried to follow the performance tips provided in the docs. But I might still be missing something. Has anyone else encountered this issue before? Is there a recommended way to improve performance in this case, or to prevent users from experiencing this kind of slowdown when working with large rule sets? For example, is there a way to rerender only the input field or the specific rule being edited instead of all the rules? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
After playing around with the code you've provided, I'm pretty sure the main problem is that your const context = useMemo(() => ({ showLabels, showBranches }), [showLabels, showBranches]);Let me know if that works! I'll investigate the demo perf later. Thanks for the heads up. |
Beta Was this translation helpful? Give feedback.
After playing around with the code you've provided, I'm pretty sure the main problem is that your
contextprop is not memoized. Internally,contextis not granularly memoized likecontrolClassnames,controlElements, andtranslations, so you have to memoize the entire object yourself. Probably just this:Let me know if that works!
I'll investigate the demo perf later. Thanks for the heads up.