Skip to content

Commit

Permalink
[fizz] Fix validateIterable call (#24166)
Browse files Browse the repository at this point in the history
* fix validate iterable call

* supports iterable

* gate test by experimental
  • Loading branch information
salazarm authored Mar 25, 2022
1 parent 3787230 commit e7d0053
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2508,4 +2508,27 @@ describe('ReactDOMFizzServer', () => {
<span>default</span>,
]);
});

// @gate experimental
it('Supports iterable', async () => {
const Immutable = require('immutable');

const mappedJSX = Immutable.fromJS([
{name: 'a', value: 'a'},
{name: 'b', value: 'b'},
]).map(item => <li key={item.get('value')}>{item.get('name')}</li>);

await act(async () => {
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(
<ul>{mappedJSX}</ul>,
);
pipe(writable);
});
expect(getVisibleChildren(container)).toEqual(
<ul>
<li>a</li>
<li>b</li>
</ul>,
);
});
});
2 changes: 1 addition & 1 deletion packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ function renderNodeDestructive(
const iteratorFn = getIteratorFn(node);
if (iteratorFn) {
if (__DEV__) {
validateIterable(node, iteratorFn());
validateIterable(node, iteratorFn);
}
const iterator = iteratorFn.call(node);
if (iterator) {
Expand Down

0 comments on commit e7d0053

Please sign in to comment.