Skip to content

Commit d222bb7

Browse files
committed
Fix/Minified React error
1 parent ec3eab9 commit d222bb7

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/components/train/own-train-button.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ import { computerMinuteOffset, get_timezones } from '@/lib/date';
77
import { useEffect, useRef } from 'react';
88
import { Button } from '../ui/button';
99
import { UseFormReturn } from 'react-hook-form';
10+
import dynamic from 'next/dynamic';
11+
12+
const NoSSR = dynamic(() => Promise.resolve(OwnTrain), {
13+
ssr: false,
14+
});
15+
16+
export default NoSSR;
1017

1118
const timezones = get_timezones();
12-
export default function OwnTrain({
19+
function OwnTrain({
1320
form,
1421
}: {
1522
form: UseFormReturn<
@@ -112,6 +119,7 @@ export default function OwnTrain({
112119
disabled={loading}
113120
onClick={handleClick}
114121
title='Training using your own revlog.'
122+
suppressHydrationWarning
115123
>
116124
Train(by own Revlog)
117125
</Button>

src/components/train/train-form.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ import FileTrain from './file-train-button';
1414
import { useForm } from 'react-hook-form';
1515
import { useTrainContext } from '@/context/TrainContext';
1616
import OwnTrain from './own-train-button';
17+
import dynamic from 'next/dynamic';
1718

18-
export default function FSRSParamTrainForm({
19+
const NoSSR = dynamic(() => Promise.resolve(FSRSParamTrainForm), {
20+
ssr: false,
21+
});
22+
23+
export default NoSSR;
24+
25+
function FSRSParamTrainForm({
1926
children,
2027
}: {
2128
children?: React.ReactNode;
@@ -30,7 +37,7 @@ export default function FSRSParamTrainForm({
3037
});
3138
return (
3239
<Form {...form}>
33-
<form className='space-y-4 w-1/2 flex justify-center flex-col flex-1'>
40+
<form className='space-y-4 w-1/2 flex justify-center flex-col flex-1' suppressHydrationWarning>
3441
<FormField
3542
control={form.control}
3643
name='timezone'

0 commit comments

Comments
 (0)