Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nomyfan opened this issue Dec 11, 2022 · 1 comment
Open

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

nomyfan opened this issue Dec 11, 2022 · 1 comment

Comments

@nomyfan
Copy link

nomyfan commented Dec 11, 2022

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

nomyfan commented Dec 11, 2022

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant