Skip to content

Commit 76447fe

Browse files
salazarmzhengjitf
authored andcommitted
[fizz] Fix validateIterable call (facebook#24166)
* fix validate iterable call * supports iterable * gate test by experimental
1 parent 2822861 commit 76447fe

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js

+23
Original file line numberDiff line numberDiff line change
@@ -2508,4 +2508,27 @@ describe('ReactDOMFizzServer', () => {
25082508
<span>default</span>,
25092509
]);
25102510
});
2511+
2512+
// @gate experimental
2513+
it('Supports iterable', async () => {
2514+
const Immutable = require('immutable');
2515+
2516+
const mappedJSX = Immutable.fromJS([
2517+
{name: 'a', value: 'a'},
2518+
{name: 'b', value: 'b'},
2519+
]).map(item => <li key={item.get('value')}>{item.get('name')}</li>);
2520+
2521+
await act(async () => {
2522+
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(
2523+
<ul>{mappedJSX}</ul>,
2524+
);
2525+
pipe(writable);
2526+
});
2527+
expect(getVisibleChildren(container)).toEqual(
2528+
<ul>
2529+
<li>a</li>
2530+
<li>b</li>
2531+
</ul>,
2532+
);
2533+
});
25112534
});

packages/react-server/src/ReactFizzServer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ function renderNodeDestructive(
11811181
const iteratorFn = getIteratorFn(node);
11821182
if (iteratorFn) {
11831183
if (__DEV__) {
1184-
validateIterable(node, iteratorFn());
1184+
validateIterable(node, iteratorFn);
11851185
}
11861186
const iterator = iteratorFn.call(node);
11871187
if (iterator) {

0 commit comments

Comments
 (0)