-
Notifications
You must be signed in to change notification settings - Fork 45.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add enableSuspenseServerRenderer feature flag #13573
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); | ||
|
||
let React; | ||
let ReactDOM; | ||
let ReactDOMServer; | ||
let ReactFeatureFlags; | ||
|
||
function initModules() { | ||
// Reset warning cache. | ||
jest.resetModuleRegistry(); | ||
|
||
ReactFeatureFlags = require('shared/ReactFeatureFlags'); | ||
ReactFeatureFlags.enableSuspense = true; | ||
ReactFeatureFlags.enableSuspenseServerRenderer = true; | ||
|
||
React = require('react'); | ||
ReactDOM = require('react-dom'); | ||
ReactDOMServer = require('react-dom/server'); | ||
|
||
// Make them available to the helpers. | ||
return { | ||
ReactDOM, | ||
ReactDOMServer, | ||
}; | ||
} | ||
|
||
const {resetModules, serverRender} = ReactDOMServerIntegrationUtils( | ||
initModules, | ||
); | ||
|
||
describe('ReactDOMServerPlaceholders', () => { | ||
beforeEach(() => { | ||
resetModules(); | ||
}); | ||
|
||
it('should always render the fallback when a placeholder is encountered', async () => { | ||
const Suspended = props => { | ||
throw new Promise(() => {}); | ||
}; | ||
const e = await serverRender( | ||
<React.Placeholder fallback={<div />}> | ||
<Suspended /> | ||
</React.Placeholder>, | ||
); | ||
|
||
expect(e.tagName).toBe('DIV'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ export const { | |
debugRenderPhaseSideEffects, | ||
debugRenderPhaseSideEffectsForStrictMode, | ||
enableGetDerivedStateFromCatch, | ||
enableSuspenseServerRenderer, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally we would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was planning on controlling this in www like so: https://fburl.com/diff/i1l0949n. let me know if you'd rather just hard-code the value here. |
||
replayFailedUnitOfWorkWithInvokeGuardedCallback, | ||
warnAboutDeprecatedLifecycles, | ||
} = require('ReactFeatureFlags'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's worth adding this to the existing renderer, even in this limited form. If we do, we should emit a warning so people know to migrate to the new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to only enable this flag in the FB build for now since we're already using placeholders.