Skip to content
This repository was archived by the owner on Dec 3, 2022. It is now read-only.

By default, fail fast if navigation is not found in context #37

Closed

Description

@slorber

Related to #33

We'd rather fail fast if context is not found and user use useNavigation(), with an option to allow useNavigation to return undefined, to support more advanced usecases (see the PR)

Activity

  1. satya164 commented on Aug 26, 2019

    @satya164
    Member

    We're throwing an error in navigation ex. I think it's more confusing for the user to give undefined instead of a proper error.

  2. satya164 commented on Aug 26, 2019

    @satya164
    Member

    The lint rule won't allow it, but I wonder what's wrong with having it in try catch. The order if hooks should still hold true

  3. slorber commented on Aug 28, 2019

    @slorber
    MemberAuthor

    Honestly I'd find it more easy to handle with useNavigation({optional: true}) or something, would require less boilerplate for people wanting to use this (I do), and we can create TS overloaded functions to return navigation | undefined

  4. satya164 commented on Aug 28, 2019

    @satya164
    Member

    idk, it seems to be a very specific use case. I'd rather export NavigationContext for advanced cases so users can access it with useContext(NavigationContext) if they don't want an error thrown for incorrect usage.

  5. slorber commented on Aug 28, 2019

    @slorber
    MemberAuthor

    Yes that would do the job too :) don't know why I didn't think of that 👍

  6. slorber commented on Aug 29, 2019

    @slorber
    MemberAuthor

    Will be fixed by #38, going to merge/release soon

  7. slorber commented on Aug 31, 2019

    @slorber
    MemberAuthor

    should be fixed by release 1.0.3 and #38, please tell me if everything works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions