question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[react-navigation] Missing tests for createAppContainer

See original GitHub issue

I 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:open
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Ashoatcommented, Jan 20, 2020

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.

0reactions
kubilaykiymacicommented, May 7, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: The navigation prop is missing for this ...
Definitely, it's because updates in react-navigation library: const App = createAppContainer(SimpleApp); export default App;.
Read more >
Troubleshooting | React Navigation
Now rebuild the app and test on your device or simulator. I'm getting an error "requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager"​....
Read more >
Invariant Violation: The navigation prop is ... - Edward Beazer
Build error after upgrading to React Navigation 3. ... createAppContainer } from 'react-navigation'; import ScreenOne from '.
Read more >
React Native Navigation: Tutorial with examples
In the latest release, there is now an official React Navigation plugin to make the testing process easier. What is React Native Navigation?...
Read more >
Setup Jest Tests with React Navigation
Say we've got the following app. It's composed of 2 stack navigators and a total of 3 screens. App.js. import React from 'react'Β ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found