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
slorber opened this issue Aug 26, 2019 · 7 comments
Closed

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

slorber opened this issue Aug 26, 2019 · 7 comments

Comments

@slorber
Copy link
Member

slorber commented Aug 26, 2019

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)

@satya164
Copy link
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.

@satya164
Copy link
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

@slorber
Copy link
Member Author

slorber commented Aug 28, 2019

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

@satya164
Copy link
Member

satya164 commented Aug 28, 2019

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.

@slorber
Copy link
Member Author

slorber commented Aug 28, 2019

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

This was referenced Aug 29, 2019
@slorber
Copy link
Member Author

slorber commented Aug 29, 2019

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

@slorber
Copy link
Member Author

slorber commented Aug 31, 2019

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

@slorber slorber closed this as completed Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants