Skip to content

Commit 63e0af1

Browse files
committed
Tiny performance improvement for unmount option hook
1 parent fac1544 commit 63e0af1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const isArray = Array.isArray;
2121
const assign = Object.assign;
2222

2323
// Global state for the current render pass
24-
let beforeDiff, afterDiff, renderHook;
24+
let beforeDiff, afterDiff, renderHook, ummountHook;
2525

2626
/**
2727
* Render Preact JSX + Components to an HTML string.
@@ -42,6 +42,7 @@ export default function renderToString(vnode, context) {
4242
beforeDiff = options[DIFF];
4343
afterDiff = options[DIFFED];
4444
renderHook = options[RENDER];
45+
ummountHook = options.unmount;
4546

4647
const parent = h(Fragment, null);
4748
parent[CHILDREN] = [vnode];
@@ -229,7 +230,7 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
229230
if (afterDiff) afterDiff(vnode);
230231
vnode[PARENT] = undefined;
231232

232-
if (options.unmount) options.unmount(vnode);
233+
if (ummountHook) ummountHook(vnode);
233234

234235
return str;
235236
}
@@ -346,7 +347,7 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
346347

347348
if (afterDiff) afterDiff(vnode);
348349
vnode[PARENT] = undefined;
349-
if (options.unmount) options.unmount(vnode);
350+
if (ummountHook) ummountHook(vnode);
350351

351352
// Emit self-closing tag for empty void elements:
352353
if (!html) {

0 commit comments

Comments
 (0)