Skip to content
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

[Flare] Fix SSR issue with serializing responders prop #16227

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
let React;
let ReactFeatureFlags;
let ReactDOM;
let ReactDOMServer;
let ReactTestRenderer;

// FIXME: What should the public API be for setting an event's priority? Right
Expand Down Expand Up @@ -72,6 +73,7 @@ describe('DOMEventResponderSystem', () => {
ReactFeatureFlags.enableFlareAPI = true;
React = require('react');
ReactDOM = require('react-dom');
ReactDOMServer = require('react-dom/server');
container = document.createElement('div');
document.body.appendChild(container);
});
Expand All @@ -93,6 +95,14 @@ describe('DOMEventResponderSystem', () => {
expect(renderer).toMatchRenderedOutput(<div>Hello world</div>);
});

it('can render correctly with the ReactDOMServer', () => {
const TestResponder = createEventResponder({});
const output = ReactDOMServer.renderToString(
<div responders={<TestResponder />}>Hello world</div>,
);
expect(output).toBe(`<div data-reactroot="">Hello world</div>`);
});

it('the event responders should fire on click event', () => {
let eventResponderFiredCount = 0;
let eventLog = [];
Expand Down
8 changes: 3 additions & 5 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,6 @@ const RESERVED_PROPS = {
suppressHydrationWarning: null,
};

if (enableFlareAPI) {
// $FlowFixMe: Flow doesn't like this, it's temp until we remove the flag anyway
RESERVED_PROPS.responders = null;
}

function createOpenTagMarkup(
tagVerbatim: string,
tagLowercase: string,
Expand All @@ -365,6 +360,9 @@ function createOpenTagMarkup(
if (!hasOwnProperty.call(props, propKey)) {
continue;
}
if (enableFlareAPI && propKey === 'responders') {
continue;
}
let propValue = props[propKey];
if (propValue == null) {
continue;
Expand Down