Skip to content

Commit 87554f7

Browse files
committed
remove Hydration code
1 parent 45885c7 commit 87554f7

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

pages/license-filter.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { FeatureAttitude, filterLicenses, InfectionRange, License } from 'license-filter';
1+
import {
2+
FeatureAttitude,
3+
filterLicenses,
4+
InfectionRange,
5+
License,
6+
} from 'license-filter';
27
import { observer } from 'mobx-react';
38
import { FC, useContext, useEffect, useState } from 'react';
4-
import { Accordion, Button, ButtonGroup, Container, ProgressBar } from 'react-bootstrap';
9+
import {
10+
Accordion,
11+
Button,
12+
ButtonGroup,
13+
Container,
14+
ProgressBar,
15+
} from 'react-bootstrap';
516

617
import { PageHead } from '../components/Layout/PageHead';
718
import { licenseTips, optionValue } from '../components/License/helper';
@@ -34,14 +45,9 @@ const LicenseTool: FC = observer(() => {
3445
const [filterOption, setFilterOption] = useState({});
3546
const [disableChoose, setDisableChoose] = useState(false);
3647
const [lists, setLists] = useState<List[]>([]);
37-
const [isHydrated, setIsHydrated] = useState(false);
3848

3949
const now = Math.ceil(100 / choiceSteps.length);
4050

41-
useEffect(() => {
42-
setIsHydrated(true);
43-
}, []);
44-
4551
useEffect(() => {
4652
if (stepIndex === choiceSteps.length) setDisableChoose(true);
4753
}, [stepIndex]);
@@ -72,7 +78,11 @@ const LicenseTool: FC = observer(() => {
7278
setFilterOption(newObject);
7379

7480
setStepIndex(
75-
stepIndex === choiceSteps.length ? stepIndex - 2 : stepIndex > 0 ? stepIndex - 1 : stepIndex,
81+
stepIndex === choiceSteps.length
82+
? stepIndex - 2
83+
: stepIndex > 0
84+
? stepIndex - 1
85+
: stepIndex,
7686
);
7787
setKeyIndex(keyIndex > 0 ? keyIndex - 1 : keyIndex);
7888

@@ -99,7 +109,7 @@ const LicenseTool: FC = observer(() => {
99109
className="mb-3"
100110
variant="info"
101111
now={(keyIndex + 1) * now}
102-
label={isHydrated ? t('step_x', { step: keyIndex + 1 }) : undefined}
112+
label={t('step_x', { step: keyIndex + 1 })}
103113
/>
104114
<Button className="mb-2" variant="warning" onClick={backToLast}>
105115
{t('last_step')}
@@ -193,4 +203,4 @@ function renderInfo({ link, feature }: License, { t }: typeof i18n) {
193203
);
194204
}
195205

196-
export default LicenseTool;
206+
export default LicenseTool;

0 commit comments

Comments
 (0)