Skip to content

[BUG] Component state bleeds between routes #5

@DaleStack

Description

@DaleStack

📝 Describe the Bug

When navigating between two entirely different routed components that both use the use_state hook, the internal state of the first component is incorrectly carried over and injected into the second component.


Minimal Reproducible Example

To reproduce this, make two distinct components that use state, and a navigation bar to swap them:

  1. Make a CounterPage component using use_state(0) with an increment button.
  2. Make a TypePage component using use_state("") with a text input.
  3. Make a NavBar with <Link> components pointing to /counter and /type.
  4. Wrap them in a Router inside the main App component.

🔁 Steps to Reproduce

Steps to reproduce the behavior:

  1. Load the app and click the link to /counter.
  2. Click the increment button until the state reaches 2.
  3. Click the link to /type.
  4. Bug 1: The text input is pre-filled with the integer 2.
  5. Type the string "hello" into the input field.
  6. Click the link to go back to /counter.
  7. Bug 2: The counter display now shows the string "hello".

✅ Expected Behavior

Components should have their own state


💻 Environment

  • OS: Windows
  • Python Version: 3.13
  • Pyponent Version: v0.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions