Skip to content

Commit e62db55

Browse files
committed
refactor(ui): use hydration-safe dropdown mount check
1 parent 39b8e7c commit e62db55

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/components/layout/products-dropdown-client.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"use client";
22

3-
import { useEffect, useState } from "react";
3+
import { useSyncExternalStore } from "react";
44
import { ProductsDropdown } from "./products-dropdown";
55

6-
export function ProductsDropdownClient() {
7-
const [mounted, setMounted] = useState(false);
6+
const emptySubscribe = () => () => {};
87

9-
useEffect(() => {
10-
setMounted(true);
11-
}, []);
8+
export function ProductsDropdownClient() {
9+
const mounted = useSyncExternalStore(emptySubscribe, () => true, () => false);
1210

1311
if (!mounted) {
1412
return null;

0 commit comments

Comments
 (0)