10000 [TypeScript] onStateChange should be typed to allow async functions · Issue #10404 · react-navigation/react-navigation · GitHub
[go: up one dir, main page]

Skip to content
[TypeScript] onStateChange should be typed to allow async functions #10404
@eliw00d

Description

@eliw00d

Current behavior

An example here shows an async function being passed to onStateChange.

However, when using TypeScript in a component that wraps NavigationContainer and doing the same thing, I get the following lint error:

95:21  error  Promise-returning function provided to attribute where a void return was expected  @typescript-eslint/no-misused-promises

Expected behavior

When using TypeScript in a component that wraps NavigationContainer and giving onStateChange an async function, the type for onStateChange allows for a Promise being returned.

Reproduction

https://github.com/eliw00d/react-navigation-issues-repro

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-bottom-tabs
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack

Environment

  • I've removed the packages that I don't use
package version
@react-navigation/native 6.0.8
node 16.13.0
yarn 3.0.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0