Skip to content

Commit a943366

Browse files
authored
Fix ssr when generate uuid (#162)
* feat: add nextjs example * fix(example/nextjs): import file outside `src` * fix: fix uuid in ssr * feat: remove nextjs example
1 parent 663dde8 commit a943366

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/devTool.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ export const DevTool = <T extends FieldValues>(props?: {
2828
}) => {
2929
const methods = useFormContext();
3030

31-
const uuid = React.useMemo(() => generateUUID(), []);
31+
const uuid = React.useRef('');
32+
33+
React.useEffect(() => {
34+
uuid.current = generateUUID();
35+
}, []);
3236

3337
const { isExtensionEnabled } = useExportControlToExtension({
34-
id: props?.id ?? uuid,
38+
id: props?.id ?? uuid.current,
3539
control: props?.control ?? methods.control,
3640
});
3741
if (isExtensionEnabled) {

0 commit comments

Comments
 (0)