mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Move SuspenseList to experimental package (#17130)
Also moves `withSuspenseConfig`
This commit is contained in:
@@ -85,7 +85,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
ReactDOMServer = require('react-dom/server');
|
||||
Scheduler = require('scheduler');
|
||||
Suspense = React.Suspense;
|
||||
SuspenseList = React.unstable_SuspenseList;
|
||||
SuspenseList = React.SuspenseList;
|
||||
|
||||
useHover = require('react-interactions/events/hover').useHover;
|
||||
});
|
||||
|
||||
@@ -107,14 +107,14 @@ describe('ReactDOMServerSuspense', () => {
|
||||
|
||||
it('server renders a SuspenseList component and its children', async () => {
|
||||
const example = (
|
||||
<React.unstable_SuspenseList>
|
||||
<React.SuspenseList>
|
||||
<React.Suspense fallback="Loading A">
|
||||
<div>A</div>
|
||||
</React.Suspense>
|
||||
<React.Suspense fallback="Loading B">
|
||||
<div>B</div>
|
||||
</React.Suspense>
|
||||
</React.unstable_SuspenseList>
|
||||
</React.SuspenseList>
|
||||
);
|
||||
const element = await serverRender(example);
|
||||
const parent = element.parentNode;
|
||||
|
||||
@@ -724,7 +724,7 @@ function runActTests(label, render, unmount, rerender) {
|
||||
});
|
||||
|
||||
describe('suspense', () => {
|
||||
if (__DEV__) {
|
||||
if (__DEV__ && __EXPERIMENTAL__) {
|
||||
it('triggers fallbacks if available', async () => {
|
||||
let resolved = false;
|
||||
let resolve;
|
||||
|
||||
@@ -6,6 +6,11 @@ let Suspense;
|
||||
let SuspenseList;
|
||||
|
||||
describe('ReactSuspenseList', () => {
|
||||
if (!__EXPERIMENTAL__) {
|
||||
it("empty test so Jest doesn't complain", () => {});
|
||||
return;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
ReactFeatureFlags = require('shared/ReactFeatureFlags');
|
||||
@@ -16,7 +21,7 @@ describe('ReactSuspenseList', () => {
|
||||
ReactNoop = require('react-noop-renderer');
|
||||
Scheduler = require('scheduler');
|
||||
Suspense = React.Suspense;
|
||||
SuspenseList = React.unstable_SuspenseList;
|
||||
SuspenseList = React.SuspenseList;
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
|
||||
@@ -10,6 +10,11 @@ let TextResource;
|
||||
let textResourceShouldFail;
|
||||
|
||||
describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
if (!__EXPERIMENTAL__) {
|
||||
it("empty test so Jest doesn't complain", () => {});
|
||||
return;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
ReactFeatureFlags = require('shared/ReactFeatureFlags');
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const ReactFB = require('./src/ReactFB');
|
||||
|
||||
// TODO: decide on the top-level export form.
|
||||
// This is hacky but makes it work with both Rollup and Jest.
|
||||
module.exports = ReactFB.default || ReactFB;
|
||||
@@ -96,7 +96,6 @@ const React = {
|
||||
Profiler: REACT_PROFILER_TYPE,
|
||||
StrictMode: REACT_STRICT_MODE_TYPE,
|
||||
Suspense: REACT_SUSPENSE_TYPE,
|
||||
unstable_SuspenseList: REACT_SUSPENSE_LIST_TYPE,
|
||||
|
||||
createElement: __DEV__ ? createElementWithValidation : createElement,
|
||||
cloneElement: __DEV__ ? cloneElementWithValidation : cloneElement,
|
||||
@@ -105,14 +104,14 @@ const React = {
|
||||
|
||||
version: ReactVersion,
|
||||
|
||||
unstable_withSuspenseConfig: withSuspenseConfig,
|
||||
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals,
|
||||
};
|
||||
|
||||
if (exposeConcurrentModeAPIs) {
|
||||
React.useTransition = useTransition;
|
||||
React.useDeferredValue = useDeferredValue;
|
||||
React.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
||||
React.unstable_withSuspenseConfig = withSuspenseConfig;
|
||||
}
|
||||
|
||||
if (enableFlareAPI) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import React from './React';
|
||||
|
||||
// TODO: Temporary alias until we update the callers downstream.
|
||||
React.unstable_SuspenseList = React.SuspenseList;
|
||||
|
||||
export default React;
|
||||
@@ -523,7 +523,7 @@ describe('ReactDOMTracing', () => {
|
||||
});
|
||||
|
||||
it('should properly trace interactions through a multi-pass SuspenseList render', () => {
|
||||
const SuspenseList = React.unstable_SuspenseList;
|
||||
const SuspenseList = React.SuspenseList;
|
||||
const Suspense = React.Suspense;
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
|
||||
Reference in New Issue
Block a user