Skip to content

Commit

Permalink
Add keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
n6g7 committed Sep 16, 2020
1 parent e367c04 commit 2112efe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/react/lib/Blocks.tsx
Expand Up @@ -23,22 +23,26 @@ const Blocks: React.FC<Props> = ({ blocks }) => {
// Finshing previous list
if (listType && block.type !== listType) {
const ListComponent = listMapping[listType];
elements.push(<ListComponent>{listItems}</ListComponent>);
elements.push(
<ListComponent key={`pre-${block.id}-list`}>
{listItems}
</ListComponent>
);
listType = null;
listItems = [];
}

if (!listTypes.includes(block.type)) {
elements.push(<Block block={block} />);
elements.push(<Block block={block} key={block.id} />);
continue;
}

listType = block.type as ListType;
listItems.push(<Block block={block} />);
listItems.push(<Block block={block} key={block.id} />);
}
if (listType) {
const ListComponent = listMapping[listType];
elements.push(<ListComponent>{listItems}</ListComponent>);
elements.push(<ListComponent key="last-list">{listItems}</ListComponent>);
}
return elements;
}, [blocks]);
Expand Down

0 comments on commit 2112efe

Please sign in to comment.