router icon indicating copy to clipboard operation
router copied to clipboard

component remounts when state is changed in context

Open frank1081 opened this issue 1 year ago • 1 comments

Describe the bug

Component is remounted when reading state that is changed for the first time in the context on the first page load.

Your Example Website or App

https://stackblitz.com/edit/vitejs-vite-z6bowx

Steps to Reproduce the Bug or Issue

On first page load click the button to increment the counter. Open console to see that component is remounted. (printed from useEffect) Every next time the button is clicked component does not get remounted. To observe issue again reload the page.

Expected behavior

Component should not remount.

Screenshots or Videos

No response

Platform

macOS, Safari and Chrome (126.0.6478.61)

Additional context

No response

frank1081 avatar Jun 19 '24 10:06 frank1081

Why would the component not be remounted here?

The state has changed in-between the router instantiation and rendering. The component rerendering should be expected I think.

Thoughts @schiller-manuel

SeanCassiere avatar Jul 26 '24 02:07 SeanCassiere

remounting does not happen anymore, tested with v1.52.1

https://stackblitz.com/edit/vitejs-vite-4bcuqe?file=package.json

schiller-manuel avatar Aug 31 '24 21:08 schiller-manuel