Posts

Showing posts with the label react-component

Mapping / Looping inside dumb component in React

Mapping / Looping inside dumb component in React I create a dumb component that used by so many data, but same display. The problem is, is it better dumb component to accept only native data type or array of object? since my data property is difference each table. <ScrollView> {listOfData.map(()=>( <Dumb title={data.title} description={data.description} > ))} </ScrollView> pros: No object properties dependancy cons: Need Loop in smart component which make it messy vs <ScrollView> <Dumbs data={listOfData} > </ScrollView> pros: More simple in smart component cons: The dumb component only accept specific data properties So which one better? I do use a second one and mapping it in my component.ts first to change object properties, but it make component.ts messy 2 Answers 2 I think the nicest way would be: <ScrollView> {listOfData.map((data) =...