@@ -16,7 +16,10 @@ import OrderedListItem from './components/OrderedListItem';
1616import generateKey from './utils/generateKey' ;
1717
1818type ParamsType = {
19- contentState : Object ,
19+ contentState : {
20+ blocks : ?Array < * > ,
21+ entityMap : Object ,
22+ } ,
2023 customStyles : Object ,
2124 atomicHandler : Function ,
2225 navigate ?: Function ,
@@ -29,25 +32,21 @@ export const ViewAfterList = (props: Object): React$Element<*> => (
2932 < View { ...props } />
3033) ;
3134
32- const getBlocks = ( params : ParamsType ) : ?Array < * > => {
35+ const getBlocks = ( params : ParamsType ) : ?Array < React$Element < * > > => {
3336 const {
3437 contentState,
3538 customStyles,
3639 navigate,
3740 orderedListSeparator,
3841 customBlockHandler,
3942 depthMargin,
43+ atomicHandler,
4044 } = params ;
41- let { atomicHandler } = params ;
4245
4346 if ( ! contentState . blocks ) {
4447 return null ;
4548 }
4649
47- if ( typeof atomicHandler === 'undefined' ) {
48- atomicHandler = ( item : Object ) : any => item ;
49- }
50-
5150 const counters = {
5251 'unordered-list-item' : {
5352 count : 0 ,
@@ -59,7 +58,7 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
5958 } ,
6059 } ;
6160
62- const checkCounter = ( counter : Object ) : any => {
61+ const checkCounter = ( counter : Object ) : ? React$Element < * > => {
6362 const myCounter = counter ;
6463
6564 // list types
@@ -92,7 +91,7 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
9291 } ;
9392
9493 return contentState . blocks
95- . map ( ( item : Object ) : any => {
94+ . map ( ( item : Object ) : React$Element < * > => {
9695 const itemData = {
9796 key : item . key ,
9897 text : item . text ,
@@ -128,17 +127,20 @@ const getBlocks = (params: ParamsType): ?Array<*> => {
128127 }
129128
130129 case 'atomic ': {
131- const viewBefore = checkCounter ( counters ) ;
132- const atomic = atomicHandler ( item ) ;
133- if ( viewBefore ) {
134- return (
135- < View key = { generateKey ( ) } >
136- { viewBefore }
137- { atomic }
138- </ View >
139- ) ;
130+ if ( atomicHandler ) {
131+ const viewBefore = checkCounter ( counters ) ;
132+ const atomic = atomicHandler ( item , contentState . entityMap ) ;
133+ if ( viewBefore ) {
134+ return (
135+ < View key = { generateKey ( ) } >
136+ { viewBefore }
137+ { atomic }
138+ </ View >
139+ ) ;
140+ }
141+ return atomic ;
140142 }
141- return atomicHandler ( item ) ;
143+ return item ;
142144 }
143145
144146 case 'blockquote' : {
0 commit comments