Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

How to render component dynamically in React Native

$
0
0

I have custom tab control in React Native app, which is rendered by dynamic config, like:

const TABS = [   { title: 'Tab 1', component: MyComponentOne },   { title: 'Tab 2', component: MyComponentTwo }];

title property goes for tab title, and when the tab is selected, I need to render the corresponding component into the Animated.FlatList.

How can I render MyComponentOne and MyComponentTwo dynamically, instead of doing?:

if (typeof item.component === 'MyComponentOne') return <MyComponentOne />if (typeof item.component === 'MyComponentTwo') return <MyComponentTwo />

Any ideas?


Viewing all articles
Browse latest Browse all 6290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>