score:0

Accepted answer
import {SvgIconNamespace} from "../namespaces";
import * as _icons from "./icons";
import {AbstractIconComponent} from "./icons";
import React from "react";
import {View} from "react-native";

interface ImportedIcons {
   [key: string]: React.FC<{size: number, fill: string}>
}

export class Icon extends AbstractIconComponent<SvgIconNamespace.SvgIconPropsInterface, SvgIconNamespace.SvgIconStateInterface> {

        render(): React.ReactNode {

            let iconElement = React.createElement(
                (_icons as ImportedIcons)[this.props.name!],  // Error sentence in this line!
                { size: this.props.size!, fill: this.props.fill!},
            )

            return(
                <View>
                    { iconElement }
                </View>
            );
        }

        constructor(props: SvgIconNamespace.SvgIconPropsInterface) {
            super(props)
        }

    }


Related Query

More Query from same tag