[react-navigation] Missing tests for createAppContainer
See original GitHub issueI am trying to set up flow typing with react-navigation v4, and having a difficult time. I canβt figure out how to call createAppContainer
correctly, and am getting two errors.
Iβm using flow@0.92.1, react-native@0.59.9 and react-navigation@4.0.10.
Hereβs my file:
/* @flow */
import {createAppContainer} from 'react-navigation';
import {createStackNavigator} from 'react-navigation-stack';
import {FilteringRoot} from './filtering-root';
const EntityFilterNavigator = createStackNavigator({
Main: {
screen: FilteringRoot,
},
});
export const EntityFilters = createAppContainer(EntityFilterNavigator);
And here are the errors I get:
Error βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Missing type annotation for O. O is a type parameter declared in function type [1] and was implicitly instantiated at
call of createAppContainer [2].
11β },
12β });
13β
[2] 14β export const EntityFilters = createAppContainer(EntityFilterNavigator);
15β
flow-typed/npm/react-navigation_v4.x.x.js
[1] 936β declare export function createAppContainer<S: NavigationState, O: {}>(
937β Component: NavigationNavigator<S, O, *>
938β ): NavigationContainer<S, O, *>;
Error βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Missing type annotation for S. S is a type parameter declared in function type [1] and was implicitly instantiated at
call of createAppContainer [2].
11β },
12β });
13β
[2] 14β export const EntityFilters = createAppContainer(EntityFilterNavigator);
15β
flow-typed/npm/react-navigation_v4.x.x.js
[1] 936β declare export function createAppContainer<S: NavigationState, O: {}>(
937β Component: NavigationNavigator<S, O, *>
938β ): NavigationContainer<S, O, *>;
I was hoping to find tests for createAppContainer
which would show me how to call it, but there donβt seem to be any here. I also canβt find any other issues or stack overflow questions about this. Not even the typescript docs have any help https://reactnavigation.org/docs/en/typescript.html.
@Ashoat, can you give any guidance here? It seems like a foundational piece of the puzzle that Iβm missing. I think that an example in the tests would go a long way towards helping users to understand how to use react-navigation with flow.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
Ah, youβre having trouble typing the call itself. I donβt have access to a laptop right now. Iβll try to get back to you when I do. For now I would suggest reading through the libdef and see if you can conclude what the type parameters and the result type should be.
Hi, Iβm using react-navigation 3.9.2 version and i have trouble in using the createAppContainer with flowtyped and i have same problem. According to navigation document, createAppContainer function take only one parameter which is return of createStackNavigator.