Skip to content

Commit 2e6d37f

Browse files
Dominic McPheesylvhama
Dominic McPhee
authored andcommitted
[ComboBox] Use isomorphic layout effect (#4018)
1 parent c909219 commit 2e6d37f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/Autocomplete/components/ComboBox/ComboBox.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {Popover, PopoverProps} from '../../../Popover';
88
import {ActionListItemDescriptor, Key} from '../../../../types';
99
import {KeypressListener} from '../../../KeypressListener';
1010
import {EventListener} from '../../../EventListener';
11+
import {isServer} from '../../../../utilities/target';
1112

1213
import {ComboBoxContext} from './context';
1314
import styles from './ComboBox.scss';
@@ -70,6 +71,8 @@ export function ComboBox({
7071
setFalse: forcePopoverActiveFalse,
7172
} = useToggle(false);
7273

74+
const useIsomorphicLayoutEffect = isServer ? useEffect : useLayoutEffect;
75+
7376
const id = useUniqueId('ComboBox', idProp);
7477

7578
const getActionsWithIds = useCallback(
@@ -240,7 +243,7 @@ export function ComboBox({
240243
}
241244
}, [selected, selectedOptions]);
242245

243-
useLayoutEffect(() => {
246+
useIsomorphicLayoutEffect(() => {
244247
let newNavigableOptions: (
245248
| OptionDescriptor
246249
| ActionListItemDescriptor

0 commit comments

Comments
 (0)