| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @flow |
| 8 | */ |
| 9 | |
| 10 | 'use strict'; |
| 11 | |
| 12 | // Intentionally not using named imports because Rollup uses dynamic |
| 13 | // dispatch for CommonJS interop named imports. |
| 14 | import * as React from 'react'; |
| 15 | |
| 16 | export const useSyncExternalStore = React.useSyncExternalStore; |
| 17 | |
| 18 | if (__DEV__) { |
| 19 | // Avoid transforming the `console.error` call as it would cause the built artifact |
| 20 | // to access React internals, which exist under different paths depending on the |
| 21 | // React version. |
| 22 | console['error']( |
| 23 | "The main 'use-sync-external-store' entry point is not supported; all it " + |
| 24 | "does is re-export useSyncExternalStore from the 'react' package, so " + |
| 25 | 'it only works with React 18+.' + |
| 26 | '\n\n' + |
| 27 | 'If you wish to support React 16 and 17, import from ' + |
| 28 | "'use-sync-external-store/shim' instead. It will fall back to a shimmed " + |
| 29 | 'implementation when the native one is not available.' + |
| 30 | '\n\n' + |
| 31 | "If you only support React 18+, you can import directly from 'react'.", |
| 32 | ); |
| 33 | } |