Skip to content

Commit

Permalink
Move SuspenseList to experimental package
Browse files Browse the repository at this point in the history
Also moves `withSuspenseConfig`
  • Loading branch information
acdlite committed Oct 17, 2019
1 parent d7feeb2 commit eda6cf6
Show file tree
Hide file tree
Showing 7 changed files with 22 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
9 changes: 6 additions & 3 deletions packages/react/src/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
enableFundamentalAPI,
enableScopeAPI,
} from 'shared/ReactFeatureFlags';
import {exposeConcurrentModeAPIs} from 'shared/forks/ReactFeatureFlags.test-renderer';
const React = {
Children: {
map,
Expand Down Expand Up @@ -93,7 +94,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 @@ -102,11 +102,14 @@ const React = {

version: ReactVersion,

unstable_withSuspenseConfig: withSuspenseConfig,

__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals,
};

if (exposeConcurrentModeAPIs) {
React.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
React.unstable_withSuspenseConfig = withSuspenseConfig;
}

if (enableFlareAPI) {
React.unstable_useResponder = useResponder;
React.unstable_createResponder = createResponder;
Expand Down
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 eda6cf6

Please sign in to comment.