Skip to content

Commit

Permalink
Move SuspenseList to experimental package (#17130)
Browse files Browse the repository at this point in the history
Also moves `withSuspenseConfig`
  • Loading branch information
acdlite authored Oct 18, 2019
1 parent 685ed56 commit c47f593
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
14 changes: 14 additions & 0 deletions packages/react/index.fb.js
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 2 additions & 3 deletions packages/react/src/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
15 changes: 15 additions & 0 deletions packages/react/src/ReactFB.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c47f593

Please sign in to comment.