remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53k stars 10.3k forks source link

Components recieving prop updates even though they don't match during pop eventd #6828

Closed lostPixels closed 5 years ago

lostPixels commented 5 years ago

Version

React Router DOM v 5.0.1

Steps to reproduce

Create a router <switch> statement with multiple <routes>. Click a few <link>s, then use the browser back button. Not sure if it's relevant, this is a larger React Application with Redux, and loadables.

Expected Behavior

When the back button is pressed, previously mounted but no longer relevant routes should unmount their children without changing their props.

Actual Behavior

The components mounted under the previously relevant <route> will get at least one prop update. This update contains a pathname and search that do not pass the path="/blah" validation. They also will not match the current window.location.

timdorr commented 5 years ago

Can you provide a reproduction of this problem on Codesandbox?

lostPixels commented 5 years ago

Hi Tim,

I'm afraid the app in which this is occurring is not portable enough to reproduce easily. I can see if it happens in isolation too though.

On Thu, Jul 11, 2019 at 11:44 AM Tim Dorr notifications@github.com wrote:

Can you provide a reproduction of this problem on Codesandbox?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ReactTraining/react-router/issues/6828?email_source=notifications&email_token=AAT3VG26N3FGKFOX34IL753P65IOPA5CNFSM4IBKYB2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZXDYCY#issuecomment-510540811, or mute the thread https://github.com/notifications/unsubscribe-auth/AAT3VG6PEQVMS22DEHMC3QTP65IOPANCNFSM4IBKYB2A .

-- James Merrill tothepixel.com http://www.toThePixel.com

lostPixels commented 5 years ago

I narrowed this down to the connected-react-router library. Sorry for the confusion.