GeezerVison is showing github.com — Upgrade useSyncExternalStore to alpha channel (#22662) · react/react@6bce035
File treeExpand file treeCollapse file tree Open diff view settings react-debug-tools/src/__tests__ react-reconciler/src/__tests__
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: ReactVersions.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,6 +36,7 @@ const stablePackages = { | 36 | 36 | 'react-refresh': '0.11.0', | 37 | 37 | 'react-test-renderer': ReactVersion, | 38 | 38 | 'use-subscription': '1.6.0', | | 39 | + 'use-sync-external-store': '1.0.0', | 39 | 40 | scheduler: '0.21.0', | 40 | 41 | }; | 41 | 42 |
| @@ -47,7 +48,6 @@ const experimentalPackages = [ | 47 | 48 | 'react-fs', | 48 | 49 | 'react-pg', | 49 | 50 | 'react-server-dom-webpack', | 50 | | - 'use-sync-external-store', | 51 | 51 | ]; | 52 | 52 |
| 53 | 53 | module.exports = { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1055,9 +1055,8 @@ describe('ReactHooksInspectionIntegration', () => { | 1055 | 1055 | ]); | 1056 | 1056 | }); | 1057 | 1057 |
| 1058 | | - // @gate experimental || www | 1059 | 1058 | it('should support composite useSyncExternalStore hook', () => { | 1060 | | - const useSyncExternalStore = React.unstable_useSyncExternalStore; | | 1059 | + const useSyncExternalStore = React.useSyncExternalStore; | 1061 | 1060 | function Foo() { | 1062 | 1061 | const value = useSyncExternalStore( | 1063 | 1062 | () => () => {}, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js +17-9Lines changed: 17 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,7 +18,7 @@ let ReactDOMFizzServer; | 18 | 18 | let Suspense; | 19 | 19 | let SuspenseList; | 20 | 20 | let useSyncExternalStore; | 21 | | -let useSyncExternalStoreExtra; | | 21 | +let useSyncExternalStoreWithSelector; | 22 | 22 | let PropTypes; | 23 | 23 | let textCache; | 24 | 24 | let window; | @@ -43,11 +43,23 @@ describe('ReactDOMFizzServer', () => { | 43 | 43 | Stream = require('stream'); | 44 | 44 | Suspense = React.Suspense; | 45 | 45 | SuspenseList = React.SuspenseList; | 46 | | - useSyncExternalStore = React.unstable_useSyncExternalStore; | 47 | | - useSyncExternalStoreExtra = require('use-sync-external-store/extra') | 48 | | - .useSyncExternalStoreExtra; | | 46 | + | 49 | 47 | PropTypes = require('prop-types'); | 50 | 48 |
| | 49 | + if (gate(flags => flags.source)) { | | 50 | + // The `with-selector` module composes the main `use-sync-external-store` | | 51 | + // entrypoint. In the compiled artifacts, this is resolved to the `shim` | | 52 | + // implementation by our build config, but when running the tests against | | 53 | + // the source files, we need to tell Jest how to resolve it. Because this | | 54 | + // is a source module, this mock has no affect on the build tests. | | 55 | + jest.mock('use-sync-external-store/src/useSyncExternalStore', () => | | 56 | + jest.requireActual('react'), | | 57 | + ); | | 58 | + } | | 59 | + useSyncExternalStore = React.useSyncExternalStore; | | 60 | + useSyncExternalStoreWithSelector = require('use-sync-external-store/with-selector') | | 61 | + .useSyncExternalStoreWithSelector; | | 62 | + | 51 | 63 | textCache = new Map(); | 52 | 64 |
| 53 | 65 | // Test Environment | @@ -1663,7 +1675,6 @@ describe('ReactDOMFizzServer', () => { | 1663 | 1675 | ); | 1664 | 1676 | }); | 1665 | 1677 |
| 1666 | | - // @gate supportsNativeUseSyncExternalStore | 1667 | 1678 | // @gate experimental | 1668 | 1679 | it('calls getServerSnapshot instead of getSnapshot', async () => { | 1669 | 1680 | const ref = React.createRef(); | @@ -1734,7 +1745,6 @@ describe('ReactDOMFizzServer', () => { | 1734 | 1745 |
| 1735 | 1746 | // The selector implementation uses the lazy ref initialization pattern | 1736 | 1747 | // @gate !(enableUseRefAccessWarning && __DEV__) | 1737 | | - // @gate supportsNativeUseSyncExternalStore | 1738 | 1748 | // @gate experimental | 1739 | 1749 | it('calls getServerSnapshot instead of getSnapshot (with selector and isEqual)', async () => { | 1740 | 1750 | // Same as previous test, but with a selector that returns a complex object | @@ -1767,7 +1777,7 @@ describe('ReactDOMFizzServer', () => { | 1767 | 1777 | } | 1768 | 1778 |
| 1769 | 1779 | function App() { | 1770 | | - const {env} = useSyncExternalStoreExtra( | | 1780 | + const {env} = useSyncExternalStoreWithSelector( | 1771 | 1781 | subscribe, | 1772 | 1782 | getClientSnapshot, | 1773 | 1783 | getServerSnapshot, | @@ -1815,7 +1825,6 @@ describe('ReactDOMFizzServer', () => { | 1815 | 1825 | expect(ref.current).toEqual(serverRenderedDiv); | 1816 | 1826 | }); | 1817 | 1827 |
| 1818 | | - // @gate supportsNativeUseSyncExternalStore | 1819 | 1828 | // @gate experimental | 1820 | 1829 | it( | 1821 | 1830 | 'errors during hydration force a client render at the nearest Suspense ' + | @@ -1964,7 +1973,6 @@ describe('ReactDOMFizzServer', () => { | 1964 | 1973 | }, | 1965 | 1974 | ); | 1966 | 1975 |
| 1967 | | - // @gate supportsNativeUseSyncExternalStore | 1968 | 1976 | // @gate experimental | 1969 | 1977 | it( | 1970 | 1978 | 'errors during hydration force a client render at the nearest Suspense ' + | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/__tests__/useSyncExternalStore-test.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,7 +36,7 @@ describe('useSyncExternalStore', () => { | 36 | 36 | useImperativeHandle = React.useImperativeHandle; | 37 | 37 | forwardRef = React.forwardRef; | 38 | 38 | useRef = React.useRef; | 39 | | - useSyncExternalStore = React.unstable_useSyncExternalStore; | | 39 | + useSyncExternalStore = React.useSyncExternalStore; | 40 | 40 | startTransition = React.startTransition; | 41 | 41 |
| 42 | 42 | act = require('jest-react').act; | @@ -70,7 +70,6 @@ describe('useSyncExternalStore', () => { | 70 | 70 | }; | 71 | 71 | } | 72 | 72 |
| 73 | | - // @gate supportsNativeUseSyncExternalStore | 74 | 73 | test( | 75 | 74 | 'detects interleaved mutations during a concurrent read before ' + | 76 | 75 | 'layout effects fire', | |
Collapse file Copy file name to clipboardExpand all lines: packages/react/index.classic.fb.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -54,7 +54,6 @@ export { | 54 | 54 | useMutableSource, | 55 | 55 | useMutableSource as unstable_useMutableSource, | 56 | 56 | useSyncExternalStore, | 57 | | - useSyncExternalStore as unstable_useSyncExternalStore, | 58 | 57 | useReducer, | 59 | 58 | useRef, | 60 | 59 | useState, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react/index.experimental.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,7 +47,7 @@ export { | 47 | 47 | useLayoutEffect, | 48 | 48 | useMemo, | 49 | 49 | useMutableSource as unstable_useMutableSource, | 50 | | - useSyncExternalStore as unstable_useSyncExternalStore, | | 50 | + useSyncExternalStore, | 51 | 51 | useReducer, | 52 | 52 | useRef, | 53 | 53 | useState, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react/index.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -73,7 +73,6 @@ export { | 73 | 73 | useMemo, | 74 | 74 | useMutableSource, | 75 | 75 | useSyncExternalStore, | 76 | | - useSyncExternalStore as unstable_useSyncExternalStore, | 77 | 76 | useReducer, | 78 | 77 | useRef, | 79 | 78 | useState, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react/index.modern.fb.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,7 +53,6 @@ export { | 53 | 53 | useMutableSource, | 54 | 54 | useMutableSource as unstable_useMutableSource, | 55 | 55 | useSyncExternalStore, | 56 | | - useSyncExternalStore as unstable_useSyncExternalStore, | 57 | 56 | useReducer, | 58 | 57 | useRef, | 59 | 58 | useState, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react/index.stable.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,6 +40,7 @@ export { | 40 | 40 | useLayoutEffect, | 41 | 41 | useMemo, | 42 | 42 | useMutableSource as unstable_useMutableSource, | | 43 | + useSyncExternalStore, | 43 | 44 | useReducer, | 44 | 45 | useRef, | 45 | 46 | useState, | |
Collapse file Copy file name to clipboardExpand all lines: packages/use-sync-external-store/index.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 |
| 10 | 10 | 'use strict'; | 11 | 11 |
| 12 | | -export * from './src/useSyncExternalStore'; | | 12 | +export {useSyncExternalStore} from './src/useSyncExternalStore'; |
|