@types/react-navigation package and had problems.Definitions by: in index.d.ts) so they can respond.Looks like we need some typings for v3 of react-navigation.
package.json:
"@types/react-navigation": "^2.13.8",
"react-navigation": "^3.0.8"
App.tsx
import { createStackNavigator, createAppContainer } from 'react-navigation';
Error:
{
"resource": "....../src/App.tsx",
"owner": "typescript",
"code": "2305",
"severity": 8,
"message": "Module '\"....../node_modules/@types/react-navigation\"' has no exported member 'createAppContainer'.",
"source": "ts",
"startLineNumber": 13,
"startColumn": 32,
"endLineNumber": 13,
"endColumn": 50
}
same with defaultNavigationOptions. really looks like somehow types were downgraded to 2.x version
"@types/react-navigation": "^2.13.8",
"react-navigation": "^3.0.8",
Error:
Object literal may only specify known properties, and 'defaultNavigationOptions' does not exist in type 'BottomTabNavigatorConfig'
Argument of type '{ initialRouteName: string; defaultNavigationOptions: ({ navigation }: any) => { animationEnabled: boolean; tabBarColor: string; tabBarOptions: { showLabel: boolean; style: { backgroundColor: string; borderTopWidth: number; borderTopColor: string; }; activeTintColor: string; inactiveTintColor: string; }; tabBarIcon:...' is not assignable to parameter of type 'BottomTabNavigatorConfig'.
Object literal may only specify known properties, and 'defaultNavigationOptions' does not exist in type 'BottomTabNavigatorConfig'.
Code:
import { createBottomTabNavigator } from 'react-navigation'
/* ... */
const Tabs = createBottomTabNavigator({
/* screens definition */
}, {
initialRouteName: INITIAL_ROUTE,
defaultNavigationOptions: ({ navigation }) => {
/* ... */
}
})
Is there any temporary solution around this?
@sorakthunly I switched to using react-navigation 2.x.x for now.
Having the same problems.
For someone else who still wants to keep the benefit of the typings while still using [email protected], I recommend trying this.
const reactNavigation = require('react-navigation');
const createAppContainer = reactNavigation.createAppContainer;
createAppContainer will not have a type definition but at least it's a temporary workgroup. With this you can also create your own type definition by doing:
export interface AppContainer {
..
}
const appContainer: AppContainer = createAppContainer(...);
@sm1th looks like this one could be closed as @types/[email protected] has been released and types for discussed methods and properties now exist:
https://www.npmjs.com/package/@types/react-navigation
@nicholasrq Super!
Most helpful comment
@sm1th looks like this one could be closed as @types/[email protected] has been released and types for discussed methods and properties now exist:
https://www.npmjs.com/package/@types/react-navigation