26459ef097
- [x] Make sure the linting passes by running `yarn lint` Back in 2019, React released the first version of `use-subscription` (https://github.com/facebook/react/pull/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` (https://github.com/reactjs/rfcs/pull/147, https://github.com/facebook/react/pull/18000): > ... enables React components to safely and efficiently read from a mutable external source in Concurrent Mode. React 18 introduces `useMutableSource`'s replacement `useSyncExternalStore` (see details here: https://github.com/reactwg/react-18/discussions/86), and React changes `use-subscription` implementation to use `useSyncExternalStore` directly: https://github.com/facebook/react/pull/24289 > In React 18, `React.useSyncExternalStore` is a built-in replacement for `useSubscription`. > > This PR makes `useSubscription` simply use `React.useSyncExternalStore` when available. For pre-18, it uses a `use-sync-external-store` shim which is very similar in `use-subscription` but fixes some flaws with concurrent rendering. And according to `use-subscription`: > You may now migrate to [`use-sync-external-store`](https://www.npmjs.com/package/use-sync-external-store) directly instead, which has the same API as `React.useSyncExternalStore`. The `use-subscription` package is now a thin wrapper over `use-sync-external-store` and will not be updated further. The PR does exactly that: - Removes the precompiled `use-subscription` introduced in #35746 - Adds the `use-sync-external-store` to the dependencies. - The `use-sync-external-store` package enables compatibility with React 16 and React 17. - Do not pre-compile `use-sync-external-store` since it is also the dependency of some popular React state management libraries like `react-redux`, `zustand`, `valtio`, `@xstate/react` and `@apollo/client`, etc. By install - Replace `useSubscription` usage with `useSyncExternalStore` --- Ref: #9026, #35746 and #36159 Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com> |
||
---|---|---|
.. | ||
i18n | ||
isomorphic | ||
page-path | ||
router | ||
amp-context.ts | ||
amp.ts | ||
constants.ts | ||
dynamic.tsx | ||
escape-regexp.ts | ||
flatten.ts | ||
flush-effects.ts | ||
head-manager-context.ts | ||
head.tsx | ||
html-context.ts | ||
image-config-context.ts | ||
image-config.ts | ||
is-plain-object.ts | ||
loadable-context.ts | ||
loadable.d.ts | ||
loadable.js | ||
match-remote-pattern.ts | ||
mitt.ts | ||
post-process.ts | ||
router-context.ts | ||
runtime-config.ts | ||
side-effect.tsx | ||
styled-jsx.d.ts | ||
styled-jsx.js | ||
utils.ts |