So i have been working on a reusable icon element that I can call in any class and just pass a string <Icon name="chat" />
that contain the specific colour of the icon .. This error is the result of the previous question I raised .. you can find the link below
I raised a question early before this:
icon.ts file
const iconsList = { heart: '', star: '', like: '', dislike: '', flash: '', marker: '', filter: '', user: '', circle: '', hashtag: '', calendar: '', chevronLeft: '', optionsV: '', optionsH: '', chat: '', explore: ''};interface Props{ name: keyof typeof iconsList;}const Icon = ({name }: Props) => { let icon = iconsList[name]; icon = icon.substr(3); icon = String.fromCharCode(parseInt(icon, 16)); return icon; };export default Icon;
profile.tsx
import React from 'react';import styles from '../assets/styles';import { ScrollView, View, Text, ImageBackground, TouchableOpacity} from 'react-native';import Icon from '../components/Icon';const Profile = () => {return (<TouchableOpacity><Text style={styles.topIconLeft}><Icon name="chevronLeft" /></Text></TouchableOpacity>);}
This line of <Icon name="chevronLeft" />
complains with an error of "JSX element type 'string' is not a constructor function for JSX elements.ts(2605)