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

React Native Typescript: Type 'string' is not assignable to type '"solid" | "clear" | "outline"'.ts(2322)

$
0
0

I am using TypeScript alongside with React Native.

import React from 'react';
import { Button } from 'react-native-elements';
import { IThemedButton } from '../../../models/themedButton';

interface IThemedButtonProps {
  data: IThemedButton;
}

const ThemedButton: React.FC<IThemedButtonProps> = ({
  data: { title, type, onPress },
}) => {
  return <Button title={title} type={type} onPress={onPress} />;
};

export default ThemedButton;

export interface IThemedButton {
  title: string;
  type: string;
  onPress: any;
}

I set type to string, because the button title is a string, but VS Code shows me an error:

Type 'string' is not assignable to type '"solid" | "clear" | "outline"'.ts(2322)
index.d.ts(326, 3): The expected type comes from property 'type' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<Button> & Readonly<ButtonProps> & Readonly<{ children?: ReactNode; }>'

I read in the docs, that the type is optional: https://react-native-training.github.io/react-native-elements/docs/button.html#type

What can be the solution?


Viewing all articles
Browse latest Browse all 6208

Trending Articles



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