React-router: Strange behaviour with alpha version

Created on 23 Sep 2018  路  7Comments  路  Source: ReactTraining/react-router

Version

4.4.0-alpha.1

Test Case

https://codesandbox.io/s/qx464vwxlj

Steps to reproduce

Click the links, check console output.

Expected Behavior

Layout component has explicit return false statement, so TestComponent shouldn't re-render when route changes.

Same example with Reach Router works well. https://codesandbox.io/s/6zv4m0wxp3

Actual Behavior

Although layout component works as expected, child component re-renders in route change. SCU doesn't prevent child re-render. (check console output after clicking links)

All 7 comments

This is already changed on master.

Hi @timdorr. Just wondering, what causes this behaviour?

setState in the Router at the top level. Causes a render on navigation. That's gone now.

Got it. Thank you so much.

@timdorr @mjackson

Test sandbox updated with latest beta version. Still same behaviour. Nothing changed.

Thanks for bringing this to my attention, @kafein. I'm looking into it. I think you may be right that using the old context API is causing that re-render. I'm going to keep looking into this.

Hi @kafein, I just confirmed that beta.3 doesn't have this issue. You can see the codesandbox here: https://codesandbox.io/s/3265w17kjq

Thanks again for bringing it to our attention :)

Was this page helpful?
0 / 5 - 0 ratings