Skip to content

CacheSwitch re-mount the same component if path changes #158

Open

Description

@nomyfan

In Switch, the component will not be re-mounted even if the path changed.
Here's a demo to reproduce.
https://stackblitz.com/edit/vitejs-vite-4923pg?file=src/App.tsx

  • Type something in the input, click Go button, then the component under CacheSwitch will be re-mounted.
  • Clear the input, and click Go button, the component under CacheSwitch will be re-mounted.

Activity

  1. nomyfan commented on Dec 11, 2022

    @nomyfan
    Author

    Switch uses React.Children.forEach to capture the matching element, while CacheSwitch uses React.Children.map to return an array(React assigns keys to each child in the array).

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions