Skip to content

Commit

Permalink
fix(ChangelogDialog): fix sb
Browse files Browse the repository at this point in the history
  • Loading branch information
Feverqwe committed Nov 10, 2023
1 parent 8b891ac commit e8e8b0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/ChangelogDialog/ChangelogDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function ChangelogDialog({
onClose,
onStoryClick,
onLinkClick,
loading = true,
loading,
}: ChangelogDialogProps) {
const idRef = React.useRef<number>();
idRef.current = idRef.current || getNextId();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useEffect} from 'react';
import React from 'react';

import {Button} from '@gravity-ui/uikit';
import type {Meta, StoryFn} from '@storybook/react';
Expand Down Expand Up @@ -79,22 +79,11 @@ const items: ChangelogItem[] = [

const DefaultTemplate: StoryFn<ChangelogDialogProps> = (props: ChangelogDialogProps) => {
const [visible, setVisible] = React.useState(props.open);
const [loading, setLoading] = React.useState(true);

React.useEffect(() => {
setVisible(props.open);
}, [props.open]);

useEffect(() => {
if (!visible) return;
const timeoutId = setTimeout(() => setLoading(false), 1000);
// eslint-disable-next-line consistent-return
return () => {
clearTimeout(timeoutId);
setLoading(true);
};
}, [visible]);

return (
<React.Fragment>
<div>
Expand All @@ -109,7 +98,6 @@ const DefaultTemplate: StoryFn<ChangelogDialogProps> = (props: ChangelogDialogPr
<ChangelogDialog
{...props}
open={visible}
loading={loading}
onClose={(event, reason) => {
setVisible(false);
props.onClose?.(event, reason);
Expand Down

0 comments on commit e8e8b0f

Please sign in to comment.