Skip to content

Commit 35cb250

Browse files
committed
style(storybook): update code style
1 parent b4c3f9b commit 35cb250

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

__stories__/FixedSizeTree.story.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {number, withKnobs} from '@storybook/addon-knobs';
22
import {storiesOf} from '@storybook/react';
3-
import * as React from 'react';
3+
import React, {FC} from 'react';
44
import AutoSizer from 'react-virtualized-auto-sizer';
55
import {
66
FixedSizeNodeComponentProps,
@@ -27,7 +27,7 @@ type StackElement = Readonly<{
2727
node: DataNode;
2828
}>;
2929

30-
type ExtendedData = FixedSizeNodeData &
30+
type TreeData = FixedSizeNodeData &
3131
Readonly<{
3232
isLeaf: boolean;
3333
name: string;
@@ -62,7 +62,7 @@ const defaultButtonStyle = {fontFamily: 'Courier New'};
6262

6363
function* treeWalker(
6464
refresh: boolean,
65-
): Generator<ExtendedData | string | symbol, void, boolean> {
65+
): Generator<TreeData | string | symbol, void, boolean> {
6666
const stack: StackElement[] = [];
6767

6868
stack.push({
@@ -95,9 +95,12 @@ function* treeWalker(
9595
}
9696
}
9797

98-
const Node: React.FunctionComponent<FixedSizeNodeComponentProps<
99-
ExtendedData
100-
>> = ({data: {isLeaf, name, nestingLevel}, isOpen, style, toggle}) => (
98+
const Node: FC<FixedSizeNodeComponentProps<TreeData>> = ({
99+
data: {isLeaf, name, nestingLevel},
100+
isOpen,
101+
style,
102+
toggle,
103+
}) => (
101104
<div
102105
style={{
103106
...style,
@@ -117,13 +120,11 @@ const Node: React.FunctionComponent<FixedSizeNodeComponentProps<
117120
</div>
118121
);
119122

120-
type TreePresenterProps = {
121-
readonly itemSize: number;
122-
};
123+
type TreePresenterProps = Readonly<{
124+
itemSize: number;
125+
}>;
123126

124-
const TreePresenter: React.FunctionComponent<TreePresenterProps> = ({
125-
itemSize,
126-
}) => (
127+
const TreePresenter: FC<TreePresenterProps> = ({itemSize}) => (
127128
<AutoSizer disableWidth>
128129
{({height}) => (
129130
<FixedSizeTree

__stories__/VariableSizeTree.story.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {number, withKnobs} from '@storybook/addon-knobs';
22
import {storiesOf} from '@storybook/react';
3-
import React, {FC} from 'react';
3+
import React, {FC, useCallback, useEffect, useRef} from 'react';
44
import AutoSizer from 'react-virtualized-auto-sizer';
55
import {
66
VariableSizeNodeComponentProps,
@@ -72,7 +72,7 @@ const Node: FC<VariableSizeNodeComponentProps<ExtendedData>> = ({
7272
const canOpen = height <= itemSize;
7373
const halfSize = itemSize / 2;
7474

75-
const toggleNodeSize = React.useCallback(
75+
const toggleNodeSize = useCallback(
7676
() => resize(canOpen ? height + halfSize : height - halfSize, true),
7777
[height, resize],
7878
);
@@ -108,12 +108,10 @@ type TreePresenterProps = Readonly<{
108108
itemSize: number;
109109
}>;
110110

111-
const TreePresenter: React.FunctionComponent<TreePresenterProps> = ({
112-
itemSize,
113-
}) => {
114-
const tree = React.useRef<VariableSizeTree<ExtendedData>>(null);
111+
const TreePresenter: FC<TreePresenterProps> = ({itemSize}) => {
112+
const tree = useRef<VariableSizeTree<ExtendedData>>(null);
115113

116-
const treeWalker = React.useCallback(
114+
const treeWalker = useCallback(
117115
function* treeWalker(
118116
refresh: boolean,
119117
): Generator<ExtendedData | string | symbol, void, boolean> {
@@ -152,7 +150,7 @@ const TreePresenter: React.FunctionComponent<TreePresenterProps> = ({
152150
[itemSize],
153151
);
154152

155-
React.useEffect(() => {
153+
useEffect(() => {
156154
// eslint-disable-next-line @typescript-eslint/no-floating-promises
157155
tree.current?.recomputeTree({
158156
refreshNodes: true,

0 commit comments

Comments
 (0)