Skip to content

Commit b2bcb3a

Browse files
committed
完善示例
1 parent a809478 commit b2bcb3a

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

stories/useList.stories.tsx renamed to stories/useList.stories.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,30 @@ export const Demo = ShowDemo({
4343
}
4444
});
4545

46-
interface UpsertDemoType {
47-
id: string;
48-
text: string;
49-
}
50-
5146
export const UpsertDemo = ShowDemo({
5247
setup() {
5348

54-
const upsertPredicate = (a: UpsertDemoType, b: UpsertDemoType) => a.id === b.id;
55-
const upsertInitialItems: UpsertDemoType[] = [
56-
{ id: '1', text: 'Sample' },
57-
{ id: '2', text: 'Example' },
49+
const upsertPredicate = (a, b) => a.id === b.id;
50+
const upsertInitialItems = [
51+
{id: '1', text: 'Sample'},
52+
{id: '2', text: 'Example'},
5853
];
5954

60-
const [list, { upsert, reset, removeAt }] = useList(upsertInitialItems);
55+
const [list, {upsert, reset, removeAt}] = useList(upsertInitialItems);
6156

6257
return () => (
63-
<div style={{ display: 'inline-flex', flexDirection: 'column' }}>
58+
<div style={{display: 'inline-flex', flexDirection: 'column'}}>
6459
{list.value.map((item, index) => (
6560
<div key={item.id}>
6661
<input
6762
value={item.text}
68-
onChange={(e: Event) => upsert(upsertPredicate, { ...item, text: e.target?.value })}
63+
onChange={(e) => upsert(upsertPredicate, {...item, text: e.target?.value})}
6964
/>
7065
<button onClick={() => removeAt(index)}>Remove</button>
7166
</div>
7267
))}
7368
<button
74-
onClick={() => upsert(upsertPredicate, { id: (list.value.length + 1).toString(), text: '' })}>
69+
onClick={() => upsert(upsertPredicate, {id: (list.value.length + 1).toString(), text: ''})}>
7570
Add item
7671
</button>
7772
<button onClick={() => reset()}>Reset</button>

stories/useMediatedState.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
argTypes: {},
88
};
99

10-
export const Docs = ShowDocs(require('../docs/useIdle.md'));
10+
// export const Docs = ShowDocs(require('../docs/useIdle.md'));
1111

1212
export const Demo = ShowDemo({
1313
setup() {

0 commit comments

Comments
 (0)