mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Set up use-sync-external-store package (#22202)
This package will be a shim for the built-in useSyncExternalStore API (not yet implemented).
This commit is contained in:
@@ -47,6 +47,7 @@ const experimentalPackages = [
|
||||
'react-fs',
|
||||
'react-pg',
|
||||
'react-server-dom-webpack',
|
||||
'use-sync-external-store',
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
|
||||
5
packages/use-sync-external-store/README.md
Normal file
5
packages/use-sync-external-store/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# use-sync-external-store
|
||||
|
||||
Backwards compatible shim for React's `useSyncExternalStore`. Works with any React that supports hooks.
|
||||
|
||||
Until `useSyncExternalStore` is documented, refer to https://github.com/reactwg/react-18/discussions/86
|
||||
12
packages/use-sync-external-store/index.js
Normal file
12
packages/use-sync-external-store/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
export * from './src/useSyncExternalStore';
|
||||
7
packages/use-sync-external-store/npm/index.js
Normal file
7
packages/use-sync-external-store/npm/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/use-sync-external-store.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/use-sync-external-store.development.js');
|
||||
}
|
||||
21
packages/use-sync-external-store/package.json
Normal file
21
packages/use-sync-external-store/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "use-sync-external-store",
|
||||
"description": "Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.",
|
||||
"version": "0.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/react.git",
|
||||
"directory": "packages/use-sync-external-store"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"build-info.json",
|
||||
"index.js",
|
||||
"cjs/"
|
||||
],
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('useSyncExternalStore', () => {
|
||||
test('TODO', () => {});
|
||||
});
|
||||
12
packages/use-sync-external-store/src/useSyncExternalStore.js
Normal file
12
packages/use-sync-external-store/src/useSyncExternalStore.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
export function useSyncExternalStore() {
|
||||
throw new Error('Not yet implemented');
|
||||
}
|
||||
@@ -684,6 +684,15 @@ const bundles = [
|
||||
externals: ['react'],
|
||||
},
|
||||
|
||||
/******* Shim for useSyncExternalState *******/
|
||||
{
|
||||
bundleTypes: [NODE_DEV, NODE_PROD],
|
||||
moduleType: ISOMORPHIC,
|
||||
entry: 'use-sync-external-store',
|
||||
global: 'useSyncExternalStore',
|
||||
externals: ['react'],
|
||||
},
|
||||
|
||||
/******* React Scheduler (experimental) *******/
|
||||
{
|
||||
bundleTypes: [
|
||||
|
||||
Reference in New Issue
Block a user