Skip to content

Commit

Permalink
[Flare] Fix SSR issue with serializing responders prop (#16227)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Jul 26, 2019
1 parent ed57bf8 commit 0d7141d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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

0 comments on commit 0d7141d

Please sign in to comment.