Skip to content

Commit bf42511

Browse files
author
liuchuan
committed
feat: 组件卸载添加resolve promise逻辑,防止内存泄漏
1 parent d598623 commit bf42511

File tree

11 files changed

+22
-11
lines changed

11 files changed

+22
-11
lines changed

.parcel-cache/2ecb2ae785209a77

4.69 MB
Binary file not shown.

.parcel-cache/599de3244968e517

1.2 MB
Binary file not shown.

.parcel-cache/5ab0f72e1c03aae5.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
62893699
2+
1697783164607299000

.parcel-cache/a9f5484dda8bfe2c

35.7 KB
Binary file not shown.

.parcel-cache/c18ce38693a82912

805 KB
Binary file not shown.

.parcel-cache/data.mdb

20.9 MB
Binary file not shown.

.parcel-cache/lock.mdb

7.94 KB
Binary file not shown.

example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
<body>
1111
<div id="root"></div>
12-
<script src="./index.tsx"></script>
12+
<script type="module" src="./index.tsx"></script>
1313
</body>
1414
</html>

example/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ const Count = () => {
1111

1212
const App = () => {
1313
const [visible, setVisible] = React.useState(false);
14+
const [destroy, setDestroy] = React.useState(false);
1415
return (
1516
<div>
16-
<button onClick={() => setVisible(!visible)}>{visible}</button>
17-
<Offscreen mode={visible ? 'visible' : 'hidden'}>
18-
<Count />
19-
</Offscreen>
17+
<button onClick={() => setVisible(!visible)}>{visible ? 'hidden' : 'show'}</button>
18+
<button onClick={() => setDestroy(true)}>destroy</button>
19+
{!destroy && (
20+
<Offscreen mode={visible ? 'visible' : 'hidden'}>
21+
<Count />
22+
</Offscreen>
23+
)}
2024
</div>
2125
);
2226
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.0",
2+
"version": "1.0.1",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",

0 commit comments

Comments
 (0)