What I'm trying to do
I wanna write mCategories's on
in require
in source
of Image tag.
Code
const mCategories = [
{
id: 1, name: 'All', off: 'all_on', on: 'all_on',
}, {
id: 2, name: 'Whole Cakes', off: 'wc', on: 'wc_on',
},
{
id: 3, name: 'Sliced Cakes', off: 'sc', on: 'sc_on',
}, {
id: 4, name: 'Chilled Items', off: 'chilled', on: 'chilled_on',
},
];
export default class Category extends React.Component {
render() {
return mCategories.map((mCategory) => (
<TouchableOpacity
key={mCategory.id}
>
<Image
source={require(`app/assets/ico/ico_category_${mCategory.on}.png`)}
/>
<Text>{mCategory.name}</Text>
</TouchableOpacity>
));
}
}
Error
Invalid call at line 28: require("app/assets/ico/ico_category_" + mCategory.on + ".png")