Skip to content

Sharing state behaves strangely when using NavigationLink #3427

Answered by stephencelis
kalupas226 asked this question in Q&A
Discussion options

You must be logged in to vote

@kalupas226 Because you are overriding the defaultAppStorage dependency in your store/reducer, the @Shared lookup is going to be different there compared to in the view, where you are creating the navigation link, and so whenever you reference shared state, like when creating your child feature's state, this needs to be done in the store/reducer, as well.

In general we think NavigationLink(state:) is probably not a tool for anything but the most basic use cases, and that you will typically have to move this logic into the reducer eventually.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kalupas226
Comment options

Answer selected by kalupas226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants