Skip to content

Commit

Permalink
chore(🤖):1.7.5 [skip ci]
Browse files Browse the repository at this point in the history
## [1.7.5](v1.7.4...v1.7.5) (2021-01-07)

### Bug Fixes

* [#11](#11) useEffect destroy函数执行时机不对 ([#13](#13)) ([c472319](c472319))
  • Loading branch information
BetaSu committed Jan 7, 2021
1 parent c472319 commit 7a31f31
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 63 deletions.
58 changes: 27 additions & 31 deletions dist/React.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* by 司徒正美 Copyright 2020-11-03
* by 司徒正美 Copyright 2021-01-07
* IE9+
*/

Expand Down Expand Up @@ -754,15 +754,15 @@
}
function useEffectImpl(create, deps, EffectTag, createList, destroyList) {
var fiber = getCurrentFiber();
var hookIndex = hookCursor;
var updateQueue = fiber.updateQueue;
if (useCallbackImpl(create, deps, false, true)) {
if (fiber.effectTag % EffectTag) {
fiber.effectTag *= EffectTag;
}
var list = updateQueue[createList] || (updateQueue[createList] = []);
updateQueue[destroyList] || (updateQueue[destroyList] = []);
list.push(create);
var depsChange = !!useCallbackImpl(create, deps, false, true);
if (depsChange && fiber.effectTag % EffectTag) {
fiber.effectTag *= EffectTag;
}
updateQueue[createList] || (updateQueue[createList] = []);
updateQueue[destroyList] || (updateQueue[destroyList] = []);
updateQueue[createList][hookIndex] = depsChange && create;
}
function useRef(initValue) {
var fiber = getCurrentFiber();
Expand Down Expand Up @@ -2827,28 +2827,24 @@
delete fiber.oldChildren;
fiber.children = {};
}
function safeInvokeHooks(upateQueue, create, destory) {
var uneffects = upateQueue[destory],
effects$$1 = upateQueue[create],
fn;
if (!uneffects) {
return;
}
while (fn = uneffects.shift()) {
try {
fn();
} catch (e) {
}
}
while (fn = effects$$1.shift()) {
try {
var f = fn();
if (typeof f === 'function') {
uneffects.push(f);
function safeInvokeHooks(upateQueue, create, destory, isUnmount) {
var prevDestroyList = upateQueue[destory];
var curCreateList = upateQueue[create];
curCreateList && curCreateList.forEach(function (createFn, i) {
var depsChange = typeof createFn === 'function';
if (depsChange || isUnmount) {
var prevDestroyFn = prevDestroyList[i];
if (typeof prevDestroyFn === 'function') {
prevDestroyFn();
}
} catch (e) {
}
}
});
!isUnmount && curCreateList && curCreateList.forEach(function (createFn, i) {
if (typeof createFn === 'function') {
var destroyFn = createFn();
prevDestroyList[i] = destroyFn;
}
});
}
function disposeFiber(fiber, force) {
var stateNode = fiber.stateNode,
Expand All @@ -2867,8 +2863,8 @@
Renderer.onDispose(fiber);
if (fiber.hasMounted) {
if (isStateless) {
safeInvokeHooks(fiber.updateQueue, 'layout', 'unlayout');
safeInvokeHooks(fiber.updateQueue, 'passive', 'unpassive');
safeInvokeHooks(fiber.updateQueue, 'layout', 'unlayout', true);
safeInvokeHooks(fiber.updateQueue, 'passive', 'unpassive', true);
}
stateNode.updater.enqueueSetState = returnFalse;
guardCallback(stateNode, 'componentWillUnmount', []);
Expand Down Expand Up @@ -3338,7 +3334,7 @@
findDOMNode: findDOMNode,
unmountComponentAtNode: unmountComponentAtNode,
unstable_renderSubtreeIntoContainer: unstable_renderSubtreeIntoContainer,
version: '1.7.3',
version: '1.7.4',
render: render$1,
hydrate: render$1,
unstable_batchedUpdates: DOMRenderer.batchedUpdates,
Expand Down
58 changes: 27 additions & 31 deletions dist/ReactIE.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* IE6+,有问题请加QQ 370262116 by 司徒正美 Copyright 2020-11-03
* IE6+,有问题请加QQ 370262116 by 司徒正美 Copyright 2021-01-07
*/

(function (global, factory) {
Expand Down Expand Up @@ -2048,15 +2048,15 @@
}
function useEffectImpl(create, deps, EffectTag, createList, destroyList) {
var fiber = getCurrentFiber();
var hookIndex = hookCursor;
var updateQueue = fiber.updateQueue;
if (useCallbackImpl(create, deps, false, true)) {
if (fiber.effectTag % EffectTag) {
fiber.effectTag *= EffectTag;
}
var list = updateQueue[createList] || (updateQueue[createList] = []);
updateQueue[destroyList] || (updateQueue[destroyList] = []);
list.push(create);
var depsChange = !!useCallbackImpl(create, deps, false, true);
if (depsChange && fiber.effectTag % EffectTag) {
fiber.effectTag *= EffectTag;
}
updateQueue[createList] || (updateQueue[createList] = []);
updateQueue[destroyList] || (updateQueue[destroyList] = []);
updateQueue[createList][hookIndex] = depsChange && create;
}
function useRef(initValue) {
var fiber = getCurrentFiber();
Expand Down Expand Up @@ -2752,28 +2752,24 @@
delete fiber.oldChildren;
fiber.children = {};
}
function safeInvokeHooks(upateQueue, create, destory) {
var uneffects = upateQueue[destory],
effects$$1 = upateQueue[create],
fn;
if (!uneffects) {
return;
}
while (fn = uneffects.shift()) {
try {
fn();
} catch (e) {
}
}
while (fn = effects$$1.shift()) {
try {
var f = fn();
if (typeof f === 'function') {
uneffects.push(f);
function safeInvokeHooks(upateQueue, create, destory, isUnmount) {
var prevDestroyList = upateQueue[destory];
var curCreateList = upateQueue[create];
curCreateList && curCreateList.forEach(function (createFn, i) {
var depsChange = typeof createFn === 'function';
if (depsChange || isUnmount) {
var prevDestroyFn = prevDestroyList[i];
if (typeof prevDestroyFn === 'function') {
prevDestroyFn();
}
} catch (e) {
}
}
});
!isUnmount && curCreateList && curCreateList.forEach(function (createFn, i) {
if (typeof createFn === 'function') {
var destroyFn = createFn();
prevDestroyList[i] = destroyFn;
}
});
}
function disposeFiber(fiber, force) {
var stateNode = fiber.stateNode,
Expand All @@ -2792,8 +2788,8 @@
Renderer.onDispose(fiber);
if (fiber.hasMounted) {
if (isStateless) {
safeInvokeHooks(fiber.updateQueue, 'layout', 'unlayout');
safeInvokeHooks(fiber.updateQueue, 'passive', 'unpassive');
safeInvokeHooks(fiber.updateQueue, 'layout', 'unlayout', true);
safeInvokeHooks(fiber.updateQueue, 'passive', 'unpassive', true);
}
stateNode.updater.enqueueSetState = returnFalse;
guardCallback(stateNode, 'componentWillUnmount', []);
Expand Down Expand Up @@ -3463,7 +3459,7 @@
unmountComponentAtNode: unmountComponentAtNode,
unstable_renderSubtreeIntoContainer: unstable_renderSubtreeIntoContainer,
miniCreateClass: miniCreateClass,
version: '1.7.3',
version: '1.7.4',
render: render$1,
hydrate: render$1,
unstable_batchedUpdates: DOMRenderer.batchedUpdates,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anujs",
"version": "1.7.4",
"version": "1.7.5",
"description": "a React16-compact mini framework",
"main": "dist/React.js",
"scripts": {
Expand Down

0 comments on commit 7a31f31

Please sign in to comment.