-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace use-subscription with use-sync-external-store #36733
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as outdated.
This comment was marked as outdated.
Stats from current PRDefault Build (Decrease detected ✓)General Overall increase
|
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
buildDuration | 15.8s | 15.7s | -121ms |
buildDurationCached | 6.4s | 6.4s | -17ms |
nodeModulesSize | 475 MB | 475 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 3.762 | 3.817 | |
/ avg req/sec | 664.56 | 654.98 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.155 | 1.169 | |
/error-in-render avg req/sec | 2163.97 | 2138.16 |
Client Bundles (main, webpack)
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
925.HASH.js gzip | 179 B | 179 B | ✓ |
framework-HASH.js gzip | 42 kB | 42 kB | ✓ |
main-HASH.js gzip | 28.8 kB | 28.8 kB | ✓ |
webpack-HASH.js gzip | 1.44 kB | 1.44 kB | ✓ |
Overall change | 72.5 kB | 72.5 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages Overall decrease ✓
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.36 kB | 1.36 kB | ✓ |
_error-HASH.js gzip | 193 B | 193 B | ✓ |
amp-HASH.js gzip | 308 B | 308 B | ✓ |
css-HASH.js gzip | 327 B | 327 B | ✓ |
dynamic-HASH.js gzip | 3.08 kB | 2.69 kB | -387 B |
head-HASH.js gzip | 359 B | 359 B | ✓ |
hooks-HASH.js gzip | 920 B | 920 B | ✓ |
image-HASH.js gzip | 5.7 kB | 5.7 kB | ✓ |
index-HASH.js gzip | 263 B | 263 B | ✓ |
link-HASH.js gzip | 2.64 kB | 2.64 kB | ✓ |
routerDirect..HASH.js gzip | 320 B | 320 B | ✓ |
script-HASH.js gzip | 391 B | 391 B | ✓ |
withRouter-HASH.js gzip | 318 B | 318 B | ✓ |
85e02e95b279..7e3.css gzip | 107 B | 107 B | ✓ |
Overall change | 16.3 kB | 15.9 kB | -387 B |
Client Build Manifests
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
_buildManifest.js gzip | 459 B | 459 B | ✓ |
Overall change | 459 B | 459 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
index.html gzip | 532 B | 532 B | ✓ |
link.html gzip | 546 B | 546 B | ✓ |
withRouter.html gzip | 528 B | 528 B | ✓ |
Overall change | 1.61 kB | 1.61 kB | ✓ |
Diffs
Diff for _buildManifest.js
@@ -8,7 +8,7 @@ self.__BUILD_MANIFEST = {
"static\u002Fchunks\u002Fpages\u002Fcss-436fa6bb26fc4120.js"
],
"/dynamic": [
- "static\u002Fchunks\u002Fpages\u002Fdynamic-80f5580e1c1b8ce3.js"
+ "static\u002Fchunks\u002Fpages\u002Fdynamic-8e11b4c2953d70e9.js"
],
"/head": ["static\u002Fchunks\u002Fpages\u002Fhead-544bb68363445a0e.js"],
"/hooks": ["static\u002Fchunks\u002Fpages\u002Fhooks-c1372eeb4916d32c.js"],
Diff for dynamic-HASH.js
@@ -255,7 +255,7 @@
});
exports["default"] = void 0;
var _react = _interopRequireDefault(__webpack_require__(7294));
- var _useSubscription = __webpack_require__(2021);
+ var _shim = __webpack_require__(1688);
var _loadableContext = __webpack_require__(3644);
function _interopRequireDefault(obj) {
return obj && obj.__esModule
@@ -308,7 +308,11 @@
var context = _react.default.useContext(
_loadableContext.LoadableContext
);
- var state = (0, _useSubscription).useSubscription(subscription);
+ var state = (0, _shim).useSyncExternalStore(
+ subscription.subscribe,
+ subscription.getCurrentValue,
+ subscription.getCurrentValue
+ );
_react.default.useImperativeHandle(
ref,
function() {
@@ -368,7 +372,7 @@
if (opts.suspense) {
opts.lazy = _react.default.lazy(opts.loader);
}
- var subscription = null;
+ /** @type LoadableSubscription */ var subscription = null;
// Server only
if (false) {
}
@@ -631,195 +635,103 @@
/***/
},
- /***/ 2021: /***/ function(
+ /***/ 5152: /***/ function(
module,
__unused_webpack_exports,
__webpack_require__
) {
- var __dirname = "/";
- (function() {
- "use strict";
- var e = {
- 800: function(e) {
- /*
-object-assign
-(c) Sindre Sorhus
-@license MIT
-*/
- var r = Object.getOwnPropertySymbols;
- var t = Object.prototype.hasOwnProperty;
- var u = Object.prototype.propertyIsEnumerable;
- function toObject(e) {
- if (e === null || e === undefined) {
- throw new TypeError(
- "Object.assign cannot be called with null or undefined"
- );
- }
- return Object(e);
- }
- function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
- var e = new String("abc");
- e[5] = "de";
- if (Object.getOwnPropertyNames(e)[0] === "5") {
- return false;
- }
- var r = {};
- for (var t = 0; t < 10; t++) {
- r["_" + String.fromCharCode(t)] = t;
- }
- var u = Object.getOwnPropertyNames(r).map(function(e) {
- return r[e];
- });
- if (u.join("") !== "0123456789") {
- return false;
- }
- var n = {};
- "abcdefghijklmnopqrst".split("").forEach(function(e) {
- n[e] = e;
- });
- if (
- Object.keys(Object.assign({}, n)).join("") !==
- "abcdefghijklmnopqrst"
- ) {
- return false;
- }
- return true;
- } catch (e) {
- return false;
- }
- }
- e.exports = shouldUseNative()
- ? Object.assign
- : function(e, n) {
- var a;
- var i = toObject(e);
- var s;
- for (var c = 1; c < arguments.length; c++) {
- a = Object(arguments[c]);
- for (var o in a) {
- if (t.call(a, o)) {
- i[o] = a[o];
- }
- }
- if (r) {
- s = r(a);
- for (var f = 0; f < s.length; f++) {
- if (u.call(a, s[f])) {
- i[s[f]] = a[s[f]];
- }
- }
- }
- }
- return i;
- };
- },
- 569: function(e, r, t) {
- /** @license React vundefined
- * use-subscription.development.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- if (false) {
- }
- },
- 403: function(e, r, t) {
- /** @license React vundefined
- * use-subscription.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var u = t(800),
- n = t(522);
- r.useSubscription = function(e) {
- var r = e.getCurrentValue,
- t = e.subscribe,
- a = n.useState(function() {
- return { getCurrentValue: r, subscribe: t, value: r() };
- });
- e = a[0];
- var i = a[1];
- a = e.value;
- if (e.getCurrentValue !== r || e.subscribe !== t)
- (a = r()), i({ getCurrentValue: r, subscribe: t, value: a });
- n.useDebugValue(a);
- n.useEffect(
- function() {
- function b() {
- if (!e) {
- var n = r();
- i(function(e) {
- return e.getCurrentValue !== r ||
- e.subscribe !== t ||
- e.value === n
- ? e
- : u({}, e, { value: n });
- });
- }
- }
- var e = !1,
- n = t(b);
- b();
- return function() {
- e = !0;
- n();
- };
- },
- [r, t]
- );
- return a;
- };
+ module.exports = __webpack_require__(7645);
+
+ /***/
+ },
+
+ /***/ 3250: /***/ function(
+ __unused_webpack_module,
+ exports,
+ __webpack_require__
+ ) {
+ "use strict";
+ /**
+ * @license React
+ * use-sync-external-store-shim.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+ var e = __webpack_require__(7294);
+ function h(a, b) {
+ return (
+ (a === b && (0 !== a || 1 / a === 1 / b)) || (a !== a && b !== b)
+ );
+ }
+ var k = "function" === typeof Object.is ? Object.is : h,
+ l = e.useState,
+ m = e.useEffect,
+ n = e.useLayoutEffect,
+ p = e.useDebugValue;
+ function q(a, b) {
+ var d = b(),
+ f = l({ inst: { value: d, getSnapshot: b } }),
+ c = f[0].inst,
+ g = f[1];
+ n(
+ function() {
+ c.value = d;
+ c.getSnapshot = b;
+ r(c) && g({ inst: c });
},
- 138: function(e, r, t) {
- if (true) {
- e.exports = t(403);
- } else {
- }
+ [a, d, b]
+ );
+ m(
+ function() {
+ r(c) && g({ inst: c });
+ return a(function() {
+ r(c) && g({ inst: c });
+ });
},
- 522: function(e) {
- e.exports = __webpack_require__(7294);
- }
- };
- var r = {};
- function __nccwpck_require__(t) {
- var u = r[t];
- if (u !== undefined) {
- return u.exports;
- }
- var n = (r[t] = { exports: {} });
- var a = true;
- try {
- e[t](n, n.exports, __nccwpck_require__);
- a = false;
- } finally {
- if (a) delete r[t];
- }
- return n.exports;
+ [a]
+ );
+ p(d);
+ return d;
+ }
+ function r(a) {
+ var b = a.getSnapshot;
+ a = a.value;
+ try {
+ var d = b();
+ return !k(a, d);
+ } catch (f) {
+ return !0;
}
- if (typeof __nccwpck_require__ !== "undefined")
- __nccwpck_require__.ab = __dirname + "/";
- var t = __nccwpck_require__(138);
- module.exports = t;
- })();
+ }
+ function t(a, b) {
+ return b();
+ }
+ var u =
+ "undefined" === typeof window ||
+ "undefined" === typeof window.document ||
+ "undefined" === typeof window.document.createElement
+ ? t
+ : q;
+ exports.useSyncExternalStore =
+ void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
/***/
},
- /***/ 5152: /***/ function(
+ /***/ 1688: /***/ function(
module,
__unused_webpack_exports,
__webpack_require__
) {
- module.exports = __webpack_require__(7645);
+ "use strict";
+
+ if (true) {
+ module.exports = __webpack_require__(3250);
+ } else {
+ }
/***/
}
Default Build with SWC (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
buildDuration | 17.8s | 17.6s | -222ms |
buildDurationCached | 6.3s | 6.4s | |
nodeModulesSize | 475 MB | 475 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 3.761 | 3.755 | -0.01 |
/ avg req/sec | 664.65 | 665.83 | +1.18 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.21 | 1.173 | -0.04 |
/error-in-render avg req/sec | 2065.9 | 2131.24 | +65.34 |
Client Bundles (main, webpack)
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
925.HASH.js gzip | 178 B | 178 B | ✓ |
framework-HASH.js gzip | 42.2 kB | 42.2 kB | ✓ |
main-HASH.js gzip | 29.2 kB | 29.2 kB | ✓ |
webpack-HASH.js gzip | 1.45 kB | 1.45 kB | ✓ |
Overall change | 73.1 kB | 73.1 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages Overall decrease ✓
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
_app-HASH.js gzip | 1.35 kB | 1.35 kB | ✓ |
_error-HASH.js gzip | 179 B | 179 B | ✓ |
amp-HASH.js gzip | 312 B | 312 B | ✓ |
css-HASH.js gzip | 324 B | 324 B | ✓ |
dynamic-HASH.js gzip | 3.08 kB | 2.71 kB | -368 B |
head-HASH.js gzip | 357 B | 357 B | ✓ |
hooks-HASH.js gzip | 921 B | 921 B | ✓ |
image-HASH.js gzip | 5.79 kB | 5.79 kB | ✓ |
index-HASH.js gzip | 261 B | 261 B | ✓ |
link-HASH.js gzip | 2.76 kB | 2.76 kB | ✓ |
routerDirect..HASH.js gzip | 322 B | 322 B | ✓ |
script-HASH.js gzip | 392 B | 392 B | ✓ |
withRouter-HASH.js gzip | 317 B | 317 B | ✓ |
85e02e95b279..7e3.css gzip | 107 B | 107 B | ✓ |
Overall change | 16.5 kB | 16.1 kB | -368 B |
Client Build Manifests
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
_buildManifest.js gzip | 456 B | 456 B | ✓ |
Overall change | 456 B | 456 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | SukkaW/next.js use-sync-external-store | Change | |
---|---|---|---|
index.html gzip | 529 B | 529 B | ✓ |
link.html gzip | 543 B | 543 B | ✓ |
withRouter.html gzip | 526 B | 526 B | ✓ |
Overall change | 1.6 kB | 1.6 kB | ✓ |
Diffs
Diff for _buildManifest.js
@@ -8,7 +8,7 @@ self.__BUILD_MANIFEST = {
"static\u002Fchunks\u002Fpages\u002Fcss-436fa6bb26fc4120.js"
],
"/dynamic": [
- "static\u002Fchunks\u002Fpages\u002Fdynamic-80f5580e1c1b8ce3.js"
+ "static\u002Fchunks\u002Fpages\u002Fdynamic-8e11b4c2953d70e9.js"
],
"/head": ["static\u002Fchunks\u002Fpages\u002Fhead-544bb68363445a0e.js"],
"/hooks": ["static\u002Fchunks\u002Fpages\u002Fhooks-c1372eeb4916d32c.js"],
Diff for dynamic-HASH.js
@@ -255,7 +255,7 @@
});
exports["default"] = void 0;
var _react = _interopRequireDefault(__webpack_require__(7294));
- var _useSubscription = __webpack_require__(2021);
+ var _shim = __webpack_require__(1688);
var _loadableContext = __webpack_require__(3644);
function _interopRequireDefault(obj) {
return obj && obj.__esModule
@@ -308,7 +308,11 @@
var context = _react.default.useContext(
_loadableContext.LoadableContext
);
- var state = (0, _useSubscription).useSubscription(subscription);
+ var state = (0, _shim).useSyncExternalStore(
+ subscription.subscribe,
+ subscription.getCurrentValue,
+ subscription.getCurrentValue
+ );
_react.default.useImperativeHandle(
ref,
function() {
@@ -368,7 +372,7 @@
if (opts.suspense) {
opts.lazy = _react.default.lazy(opts.loader);
}
- var subscription = null;
+ /** @type LoadableSubscription */ var subscription = null;
// Server only
if (false) {
}
@@ -631,195 +635,103 @@
/***/
},
- /***/ 2021: /***/ function(
+ /***/ 5152: /***/ function(
module,
__unused_webpack_exports,
__webpack_require__
) {
- var __dirname = "/";
- (function() {
- "use strict";
- var e = {
- 800: function(e) {
- /*
-object-assign
-(c) Sindre Sorhus
-@license MIT
-*/
- var r = Object.getOwnPropertySymbols;
- var t = Object.prototype.hasOwnProperty;
- var u = Object.prototype.propertyIsEnumerable;
- function toObject(e) {
- if (e === null || e === undefined) {
- throw new TypeError(
- "Object.assign cannot be called with null or undefined"
- );
- }
- return Object(e);
- }
- function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
- var e = new String("abc");
- e[5] = "de";
- if (Object.getOwnPropertyNames(e)[0] === "5") {
- return false;
- }
- var r = {};
- for (var t = 0; t < 10; t++) {
- r["_" + String.fromCharCode(t)] = t;
- }
- var u = Object.getOwnPropertyNames(r).map(function(e) {
- return r[e];
- });
- if (u.join("") !== "0123456789") {
- return false;
- }
- var n = {};
- "abcdefghijklmnopqrst".split("").forEach(function(e) {
- n[e] = e;
- });
- if (
- Object.keys(Object.assign({}, n)).join("") !==
- "abcdefghijklmnopqrst"
- ) {
- return false;
- }
- return true;
- } catch (e) {
- return false;
- }
- }
- e.exports = shouldUseNative()
- ? Object.assign
- : function(e, n) {
- var a;
- var i = toObject(e);
- var s;
- for (var c = 1; c < arguments.length; c++) {
- a = Object(arguments[c]);
- for (var o in a) {
- if (t.call(a, o)) {
- i[o] = a[o];
- }
- }
- if (r) {
- s = r(a);
- for (var f = 0; f < s.length; f++) {
- if (u.call(a, s[f])) {
- i[s[f]] = a[s[f]];
- }
- }
- }
- }
- return i;
- };
- },
- 569: function(e, r, t) {
- /** @license React vundefined
- * use-subscription.development.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- if (false) {
- }
- },
- 403: function(e, r, t) {
- /** @license React vundefined
- * use-subscription.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var u = t(800),
- n = t(522);
- r.useSubscription = function(e) {
- var r = e.getCurrentValue,
- t = e.subscribe,
- a = n.useState(function() {
- return { getCurrentValue: r, subscribe: t, value: r() };
- });
- e = a[0];
- var i = a[1];
- a = e.value;
- if (e.getCurrentValue !== r || e.subscribe !== t)
- (a = r()), i({ getCurrentValue: r, subscribe: t, value: a });
- n.useDebugValue(a);
- n.useEffect(
- function() {
- function b() {
- if (!e) {
- var n = r();
- i(function(e) {
- return e.getCurrentValue !== r ||
- e.subscribe !== t ||
- e.value === n
- ? e
- : u({}, e, { value: n });
- });
- }
- }
- var e = !1,
- n = t(b);
- b();
- return function() {
- e = !0;
- n();
- };
- },
- [r, t]
- );
- return a;
- };
+ module.exports = __webpack_require__(7645);
+
+ /***/
+ },
+
+ /***/ 3250: /***/ function(
+ __unused_webpack_module,
+ exports,
+ __webpack_require__
+ ) {
+ "use strict";
+ /**
+ * @license React
+ * use-sync-external-store-shim.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+ var e = __webpack_require__(7294);
+ function h(a, b) {
+ return (
+ (a === b && (0 !== a || 1 / a === 1 / b)) || (a !== a && b !== b)
+ );
+ }
+ var k = "function" === typeof Object.is ? Object.is : h,
+ l = e.useState,
+ m = e.useEffect,
+ n = e.useLayoutEffect,
+ p = e.useDebugValue;
+ function q(a, b) {
+ var d = b(),
+ f = l({ inst: { value: d, getSnapshot: b } }),
+ c = f[0].inst,
+ g = f[1];
+ n(
+ function() {
+ c.value = d;
+ c.getSnapshot = b;
+ r(c) && g({ inst: c });
},
- 138: function(e, r, t) {
- if (true) {
- e.exports = t(403);
- } else {
- }
+ [a, d, b]
+ );
+ m(
+ function() {
+ r(c) && g({ inst: c });
+ return a(function() {
+ r(c) && g({ inst: c });
+ });
},
- 522: function(e) {
- e.exports = __webpack_require__(7294);
- }
- };
- var r = {};
- function __nccwpck_require__(t) {
- var u = r[t];
- if (u !== undefined) {
- return u.exports;
- }
- var n = (r[t] = { exports: {} });
- var a = true;
- try {
- e[t](n, n.exports, __nccwpck_require__);
- a = false;
- } finally {
- if (a) delete r[t];
- }
- return n.exports;
+ [a]
+ );
+ p(d);
+ return d;
+ }
+ function r(a) {
+ var b = a.getSnapshot;
+ a = a.value;
+ try {
+ var d = b();
+ return !k(a, d);
+ } catch (f) {
+ return !0;
}
- if (typeof __nccwpck_require__ !== "undefined")
- __nccwpck_require__.ab = __dirname + "/";
- var t = __nccwpck_require__(138);
- module.exports = t;
- })();
+ }
+ function t(a, b) {
+ return b();
+ }
+ var u =
+ "undefined" === typeof window ||
+ "undefined" === typeof window.document ||
+ "undefined" === typeof window.document.createElement
+ ? t
+ : q;
+ exports.useSyncExternalStore =
+ void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
/***/
},
- /***/ 5152: /***/ function(
+ /***/ 1688: /***/ function(
module,
__unused_webpack_exports,
__webpack_require__
) {
- module.exports = __webpack_require__(7645);
+ "use strict";
+
+ if (true) {
+ module.exports = __webpack_require__(3250);
+ } else {
+ }
/***/
}
huozhi
reviewed
May 8, 2022
huozhi
approved these changes
May 8, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
1 task
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
yarn lint
Back in 2019, React released the first version of
use-subscription
(facebook/react#15022). At the time, we only has limited information about concurrent rendering, and #9026 add the initial concurrent mode support.In 2020, React provides a first-party official API
useMutableSource
(reactjs/rfcs#147, facebook/react#18000):React 18 introduces
useMutableSource
's replacementuseSyncExternalStore
(see details here: reactwg/react-18#86), and React changesuse-subscription
implementation to useuseSyncExternalStore
directly: facebook/react#24289And according to
use-subscription
:The PR does exactly that:
use-subscription
introduced in Update to pre-compile use-subscription #35746use-sync-external-store
to the dependencies.use-sync-external-store
package enables compatibility with React 16 and React 17.use-sync-external-store
since it is also the dependency of some popular React state management libraries likereact-redux
,zustand
,valtio
,@xstate/react
and@apollo/client
, etc. By installuseSubscription
usage withuseSyncExternalStore
Ref: #9026, #35746 and #36159