File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
app/components/form/fields Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,15 @@ export function useDateTimeRangePicker({
84
84
items,
85
85
}
86
86
87
- const [ startTime ] = useDebounce ( range . start . toDate ( tz ) , 400 )
88
- const [ endTime ] = useDebounce ( range . end . toDate ( tz ) , 400 )
87
+ // Without these useMemos, we get re-renders every 400ms because when the
88
+ // debounce timeout expires, it updates the value, which triggers a render for
89
+ // itself because the time gets remade by toDate() (i.e., even though it is
90
+ // the same time, it is a new object)
91
+ const rangeStart = useMemo ( ( ) => range . start . toDate ( tz ) , [ range . start ] )
92
+ const [ startTime ] = useDebounce ( rangeStart , 400 )
93
+
94
+ const rangeEnd = useMemo ( ( ) => range . end . toDate ( tz ) , [ range . end ] )
95
+ const [ endTime ] = useDebounce ( rangeEnd , 400 )
89
96
90
97
return {
91
98
startTime,
You can’t perform that action at this time.
0 commit comments