Dynamic Card Support in Native base 2.0.0
Hi,
I have upgraded Native base to latest one but I am unable to repeat Cards. Please help me to solve this.
Thanks,
It is very similar to List, in the way they are iterated. Please check here
@sanketsahusoft can you provide code snippet for dynamic List of Cards.
I think you meant @sankhadeeproy007
oh its typo mistake. yep I meant @sankhadeeproy007
@sankhadeeproy007 passing an array to dataArray and a function to renderRow in a <Card> component throws Warning: Failed prop type: Invalid prop `dataArray` of type `array` supplied to `Card`, expected `object and Warning: Failed prop type: Invalid prop `renderRow` of type `function` supplied to `Card`, expected `object respectively.
Those are only warnings, so it's still displayed correctly, but before 2.0 I was not getting those warnings.
Same warning as @stefano-DM for dataArray (array) and renderRow (function) Can someone share a working dynamic card snippet? (Nativebase >= 2.0)
I was able to solve this by using <List dataArray{arr} renderRow{(item) => ... }> //Card stuff goes here </List>.
I think <Card dataArray & renderRow> expects object as seen from here and here.
But with giving data to <List> this problem can be easily escaped.
const StudentCard = props => {
const { data, gotoStudent } = props
return (
<List dataArray={data} renderRow={(item) =>
<Card>
<CardItem header>
<Text style={{fontWeight: 'bold'}}>
{item['school_name']}
</Text>
</CardItem>
<CardItem cardBody>
<Col>
<Text>
{item['student_name']}
</Text>
</Col>
<Col>
<Text>
{item['school_number']}/{item['student_number']}/{item['examYear']}
</Text>
</Col>
</CardItem>
<CardItem footer>
<Text>
{item['examType']}
</Text>
</CardItem>
</Card>
}>
</List>
)
}
Got the idea from this dude's code