Skip to content

Commit d5dbb6f

Browse files
author
Raphael Freitas
committed
Fix keys for atomics
1 parent 3ddb5b3 commit d5dbb6f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

sample/__tests__/getBlocks.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('return specific component based on type', () => {
6868
] };
6969
const atomicHandler = item => item;
7070
const result = getBlocks({ contentState: bodyData, atomicHandler });
71-
expect(result[1][1].type).toBe('atomic');
71+
expect(result[1].props.children[1].type).toBe('atomic');
7272
});
7373

7474
it('array of null when type is invalid', () => {

src/getBlocks.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,15 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
117117
}
118118

119119
case 'atomic': {
120-
const separator = checkCounter(counters);
121-
if (separator) {
122-
const atomicView = [];
123-
atomicView.push(separator);
124-
atomicView.push(atomicHandler(item));
125-
return atomicView;
120+
const viewBefore = checkCounter(counters);
121+
const atomic = atomicHandler(item);
122+
if (viewBefore) {
123+
return (
124+
<View key={generateKey()}>
125+
{viewBefore}
126+
{atomic}
127+
</View>
128+
);
126129
}
127130
return atomicHandler(item);
128131
}

0 commit comments

Comments
 (0)