Answer the question
In order to leave comments, you need to log in
How to dynamically render different components in React Native?
For example, I have a store with the following data:
Page: [
{type: 'Button', label: 'Ok'},
{type: 'Card', label: 'News', Image: 'request...'},
{ type: 'TextInput', placeholder: 'Hello'}
];
These components need to be dynamically rendered on the page. But for example flatList renders components of only one type. How can this be implemented?
Answer the question
In order to leave comments, you need to log in
It's better to change the structure:
[
{
type: 'Button',
props: {
label: 'Ok'
}
},
{
type: 'Card',
props: {
label: 'News',
Image: 'request...'
}
},
{
type: 'TextInput',
props: {
placeholder: 'Hello'
}
}
];
render
:{{page.map(element => <element.type {...element.props} />)}}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question