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

Unhandled promise rejection [Error: Got an invalid value for 'component' prop for the screen 'LocationType'. It must be a valid React Component.]

$
0
0

So I am trying to convert a string to an enum type and use it as a type in useState:

From

const [someType, setSomeType] = useState<"water", "air", "fire">("water")

This works fine but when I try to convert this to an enum type like

export enum SomeType {  WATER,  AIR,  FIRE,}  const [someType, setSomeType] = useState<SomeType>(SomeType.WATER)

this throws and error

Unhandled promise rejection [Error: Got an invalid value for 'component' prop for the screen 'SomeType'. It must be a valid React Component.]

I have tried other ways too like

const [someType, setSomeType] = useState<SomeType.WATER | SomeType.AIR | SomeType.FIRE>(SomeType.WATER)

But the error is the same, Am I missing something here?


Viewing all articles
Browse latest Browse all 6287

Trending Articles