Skip to content

Commit 406784a

Browse files
committed
Initialize preservedControlledValueRef with value
We got an error from users about'shown' in useFloatingWithInteractions hook TypeError: Uncaught TypeError: Cannot read properties of undefined (reading 'shown') I wasn't able to catch this locally, or in test env, but to make sure preservedControlledValueRef can't be undefined if value is defind we give it a value.
1 parent 7d4f104 commit 406784a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/vkui/src/hooks/useEnsuredControl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function useCustomEnsuredControl<V = any>({
4646
}: UseCustomEnsuredControlProps<V>): [V, React.Dispatch<React.SetStateAction<V>>] {
4747
const isControlled = value !== undefined;
4848
const [localValue, setLocalValue] = React.useState(defaultValue);
49-
const preservedControlledValueRef = React.useRef<V>();
49+
const preservedControlledValueRef = React.useRef(value);
5050

5151
useIsomorphicLayoutEffect(() => {
5252
preservedControlledValueRef.current = value;

0 commit comments

Comments
 (0)