Skip to content

Commit

Permalink
Support ref cleanup function for imperative handle refs (#28910)
Browse files Browse the repository at this point in the history
Support ref cleanup function for imperative handle refs

DiffTrain build for commit ed71a3a.
  • Loading branch information
kassens committed Apr 25, 2024
1 parent ef8407b commit dfb541e
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<901259dbb520cffda8ebd0f1c24b61d7>>
* @generated SignedSource<<52b4dbf4e18cc25f133cd7e575c1b6cd>>
*/

'use strict';
Expand Down Expand Up @@ -8548,9 +8548,14 @@ function imperativeHandleEffect(create, ref) {
if (typeof ref === 'function') {
var refCallback = ref;
var inst = create();
refCallback(inst);
var refCleanup = refCallback(inst);
return function () {
refCallback(null);
if (typeof refCleanup === 'function') {
// $FlowFixMe[incompatible-use] we need to assume no parameters
refCleanup();
} else {
refCallback(null);
}
};
} else if (ref !== null && ref !== undefined) {
var refObject = ref;
Expand Down Expand Up @@ -22983,7 +22988,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-canary-5e828dec';
var ReactVersion = '19.0.0-canary-8f31b884';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<c6fc72b49d174b33d4572246c49e569a>>
* @generated SignedSource<<bbd5884892e3e7b30fece4b277837a1e>>
*/

"use strict";
Expand Down Expand Up @@ -2824,14 +2824,13 @@ function updateLayoutEffect(create, deps) {
return updateEffectImpl(4, 4, create, deps);
}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
(create = create()),
ref(create),
function () {
ref(null);
}
);
if ("function" === typeof ref) {
create = create();
var refCleanup = ref(create);
return function () {
"function" === typeof refCleanup ? refCleanup() : ref(null);
};
}
if (null !== ref && void 0 !== ref)
return (
(create = create()),
Expand Down Expand Up @@ -9152,7 +9151,7 @@ var devToolsConfig$jscomp$inline_1028 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-canary-e1a9c38c",
version: "19.0.0-canary-23c765d3",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1247 = {
Expand Down Expand Up @@ -9183,7 +9182,7 @@ var internals$jscomp$inline_1247 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-e1a9c38c"
reconcilerVersion: "19.0.0-canary-23c765d3"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1248 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<d056995ed197f2bb9dea5e09fe3f5123>>
* @generated SignedSource<<cda6f05cc9137320b9b41d8810504f84>>
*/

"use strict";
Expand Down Expand Up @@ -2912,14 +2912,13 @@ function updateLayoutEffect(create, deps) {
return updateEffectImpl(4, 4, create, deps);
}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
(create = create()),
ref(create),
function () {
ref(null);
}
);
if ("function" === typeof ref) {
create = create();
var refCleanup = ref(create);
return function () {
"function" === typeof refCleanup ? refCleanup() : ref(null);
};
}
if (null !== ref && void 0 !== ref)
return (
(create = create()),
Expand Down Expand Up @@ -9768,7 +9767,7 @@ var devToolsConfig$jscomp$inline_1110 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-canary-71d4d884",
version: "19.0.0-canary-a8cb0ecc",
rendererPackageName: "react-test-renderer"
};
(function (internals) {
Expand Down Expand Up @@ -9812,7 +9811,7 @@ var devToolsConfig$jscomp$inline_1110 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-71d4d884"
reconcilerVersion: "19.0.0-canary-a8cb0ecc"
});
exports._Scheduler = Scheduler;
exports.act = act;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cb151849e13f46ec64570519cb93d5939fb60cab
ed71a3ad2965617c27c6e7ca7577f15b8ca4152c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e23105fe3f0439fc7cd9d5143f2ae9f4>>
* @generated SignedSource<<a0b071a4d2d0e560cdb146b2f45c1c18>>
*/

'use strict';
Expand Down Expand Up @@ -11525,9 +11525,14 @@ function imperativeHandleEffect(create, ref) {
if (typeof ref === 'function') {
var refCallback = ref;
var inst = create();
refCallback(inst);
var refCleanup = refCallback(inst);
return function () {
refCallback(null);
if (typeof refCleanup === 'function') {
// $FlowFixMe[incompatible-use] we need to assume no parameters
refCleanup();
} else {
refCallback(null);
}
};
} else if (ref !== null && ref !== undefined) {
var refObject = ref;
Expand Down Expand Up @@ -26066,7 +26071,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-canary-e93cff57';
var ReactVersion = '19.0.0-canary-f568fe98';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<d3b7614abf5c86177b115750e157b71a>>
* @generated SignedSource<<06016018fb347358b18b57d695069089>>
*/

"use strict";
Expand Down Expand Up @@ -4384,14 +4384,13 @@ function updateLayoutEffect(create, deps) {
return updateEffectImpl(4, 4, create, deps);
}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
(create = create()),
ref(create),
function () {
ref(null);
}
);
if ("function" === typeof ref) {
create = create();
var refCleanup = ref(create);
return function () {
"function" === typeof refCleanup ? refCleanup() : ref(null);
};
}
if (null !== ref && void 0 !== ref)
return (
(create = create()),
Expand Down Expand Up @@ -10610,7 +10609,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1108 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-canary-44e696d7",
version: "19.0.0-canary-b5226534",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10653,7 +10652,7 @@ var internals$jscomp$inline_1375 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-44e696d7"
reconcilerVersion: "19.0.0-canary-b5226534"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1376 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e5a82a39e932ccf268d8c43e0fd08541>>
* @generated SignedSource<<0348b9e6ebecc00eaa767ca2f98fb9d8>>
*/

"use strict";
Expand Down Expand Up @@ -4506,14 +4506,13 @@ function updateLayoutEffect(create, deps) {
return updateEffectImpl(4, 4, create, deps);
}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
(create = create()),
ref(create),
function () {
ref(null);
}
);
if ("function" === typeof ref) {
create = create();
var refCleanup = ref(create);
return function () {
"function" === typeof refCleanup ? refCleanup() : ref(null);
};
}
if (null !== ref && void 0 !== ref)
return (
(create = create()),
Expand Down Expand Up @@ -11315,7 +11314,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1188 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-canary-1d21c404",
version: "19.0.0-canary-7c054062",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -11371,7 +11370,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-1d21c404"
reconcilerVersion: "19.0.0-canary-7c054062"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<eb0c79f9647d9ccb19601e79d168e28a>>
* @generated SignedSource<<429d382e81c12cadfefde85a5059684a>>
*/

'use strict';
Expand Down Expand Up @@ -11764,9 +11764,14 @@ function imperativeHandleEffect(create, ref) {
if (typeof ref === 'function') {
var refCallback = ref;
var inst = create();
refCallback(inst);
var refCleanup = refCallback(inst);
return function () {
refCallback(null);
if (typeof refCleanup === 'function') {
// $FlowFixMe[incompatible-use] we need to assume no parameters
refCleanup();
} else {
refCallback(null);
}
};
} else if (ref !== null && ref !== undefined) {
var refObject = ref;
Expand Down Expand Up @@ -26481,7 +26486,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-canary-f458e15c';
var ReactVersion = '19.0.0-canary-6d8999b7';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<50ed89ef9d28f94308e802dfa68cd799>>
* @generated SignedSource<<8912877d0e4069bef75f6199a4eb9f6d>>
*/

"use strict";
Expand Down Expand Up @@ -4437,14 +4437,13 @@ function updateLayoutEffect(create, deps) {
return updateEffectImpl(4, 4, create, deps);
}
function imperativeHandleEffect(create, ref) {
if ("function" === typeof ref)
return (
(create = create()),
ref(create),
function () {
ref(null);
}
);
if ("function" === typeof ref) {
create = create();
var refCleanup = ref(create);
return function () {
"function" === typeof refCleanup ? refCleanup() : ref(null);
};
}
if (null !== ref && void 0 !== ref)
return (
(create = create()),
Expand Down Expand Up @@ -10832,7 +10831,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1177 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "19.0.0-canary-e4d135f3",
version: "19.0.0-canary-b761b2f6",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10875,7 +10874,7 @@ var internals$jscomp$inline_1461 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-e4d135f3"
reconcilerVersion: "19.0.0-canary-b761b2f6"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1462 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Loading

0 comments on commit dfb541e

Please sign in to comment.