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

Spread props type in React

$
0
0

I was creating a react component for icon.

The component looks like this

import React from "react";import MIcon from "react-native-vector-icons/MaterialIcons";import MaterialIconCommunity from "react-native-vector-icons/MaterialCommunityIcons";import icons from "./names";interface Props {   name: string}const Icon = ({ name, ...props }: Props) => {  if (icons[name] === "material-community") {    return <MaterialIconCommunity name={name} {...props} />;  }  if (icons[name] === "material") {    return <MIcon name={name} {...props} />;  }

What should be the type of ...props here?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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