Skip to content

Navigating between routes containing Leva panels with a same-name field uses stale data #480

Answered by dbismut
about-hector asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, moving this to a discussion since it's not a bug.

I'm getting an error when navigating to each of the routes.

However I understand the issue.

A few things to note:

  • Leva is global to your app, and that's intentional. So if you define the same attribute (in your case width) in two different places, Leva will only create one input, and will set its initial value to the value define in the useControls hook being called first.
  • This is the default behavior because it allows components (and therefore instances of the same component) to share input values.

Luckily for you, Leva also allows you to create several stores and dynamically assign a store to a panel. This sandbox from the demo p…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@dbismut
Comment options

Answer selected by about-hector
@about-hector
Comment options

@dbismut
Comment options

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
Converted from issue

This discussion was converted from issue #478 on November 19, 2023 08:05.