/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/use-sync-external-store/src/useSyncExternalStore.js
33 строки
1 KB
Lenz Weber-Tronic
Avoid acccessing React internals from `use-sync-external-store/shim` (#29868)
12 июн 2024, 21:13
Не верифицирован
12 июн 2024, 21:13
50e89ec
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and 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'; // Intentionally not using named imports because Rollup uses dynamic // dispatch for CommonJS interop named imports. import * as React from 'react'; export const useSyncExternalStore = React.useSyncExternalStore; if (__DEV__) { // Avoid transforming the `console.error` call as it would cause the built artifact // to access React internals, which exist under different paths depending on the // React version. console['error']( "The main 'use-sync-external-store' entry point is not supported; all it " + "does is re-export useSyncExternalStore from the 'react' package, so " + 'it only works with React 18+.' + '\n\n' + 'If you wish to support React 16 and 17, import from ' + "'use-sync-external-store/shim' instead. It will fall back to a shimmed " + 'implementation when the native one is not available.' + '\n\n' + "If you only support React 18+, you can import directly from 'react'.", ); }