Closed chapman-cc closed 3 years ago
i think this is happening because you are not importing react in a file where you use jsx.
this should fix it:
import React from 'react';
import { StackNavigationOptions } from "@react-navigation/stack";
import { Ionicons } from "@expo/vector-icons";
import { Route } from "@react-navigation/native";
const screenOptions: StackNavigationOptions = ({
title: 'Home',
headerLeft: () => (<Ionicons name='menu' onPress={()=>{}} />)
// ts error: 'Ionicons' refers to a value, but is being used as a type here.
// Did you mean 'typeof Ionicons'?ts(2749)
})
export default screenOptions;
Bug: I use Ionicons in stack navigator options
headerLeft
property, as to return the Icon as JSX, but typescript thought it was a type I am not sure if this bug is a vector-icon bug or a typescript bugI'm writing a
createStackNavigator
from@react-navigation/stack
where inStack.Navigator
screen options, I tried to separated it to reuse it with another file I added a Ionicons menu at the left side of the nav bar, using a function to return a JSX.Element to propertyheaderLeft
but it returns a typescript error, saying I use Ionicons as a type but not as a value I am not sure if this bug is a vector-icon bug or a typescript bugYou can replicate this by downloading these necessary modules first:
yarn add @react-navigation/stack @expo/vector-icons @react-navigation/native
then copy below code into a new file (testFile.tsx):
however if I place it along with the Stack Navigator function it doesn't return an error, like so: