-
Notifications
You must be signed in to change notification settings - Fork 114
Rendering after back/forward inconsistent with push #144
Comments
Yikes! I'll be looking into this soon. |
I've run into this issue as well. I believe it is because import { connect } from 'react-redux'
import { Fragment as Unconnected } from 'react-little-router'
const Fragment = connect(({ router }) => ({ router }))(UnconnectedFragment)
...
<RouterProvider store={ store }>
<Provider store={ store }>
<Layout>
<Fragment forRoute='/parent'>
<Parent />
</Fragment>
<Fragment forRoute='/child'>
<Child />
</Fragment>
</Layout>
</Provider>
</RouterProvider> N.B. Even with this workaround in place, you'll need to use @tptee, I'd love to submit a PR to use |
@dpwrussell @ApeChimp can you pull down |
@tptee I'm on vacation right now and don't have access to my normal dev environment, so I can't test with @dpwrussell's repro repo. I looked at #189 though and I'm very confident that will fix it: I had tried a much less ambitious change (just removing the context stuff from |
Glad to hear! I'll leave this open until you're back and can confirm 👍 |
Hi,
Full Test Case Here: https://github.com/dpwrussell/RLRBackForwardIssueDemo
I think there is an inconsistency in the way that redux-little-router handles some route transitions when they occur because of a back/forward.
I would expect that the rendering of these two scenarios would be identical:
push
) to page 2push
) to page 1and
push
) to page 2goBack
action-creator.However, they are sometimes not identical and it breaks the notion of rendering as a function of the route. An example I hit was that I clicked back and a selector would use the route to grab the appropriate object from the store to be used to render the new page. The problem was that the object had correctly updated to the new one based on the new route, but then the old route components would attempt to rerender before the switch from one
Fragment
to another. As the two objects in my case require different components to render, the result is a nasty flicker in the best case, orredux-form
being initialised to nonsense in the worst.I tried to debug this further, but I am having a lot of trouble understanding how Fragments work now.
One useful piece of information I can provide though is that it seems to have something to do with rendering children and when a
mapStateToProps
function is provided. For example, in the below code,Layout
is what seems to cause the unwanted rerender ofChild
if pressing back fromChild
toParent
.This seems pretty serious as it means that rendering as a function of the state can not really be relied upon as the state has moved on, but what is being rendered (temporarily) has not.
The text was updated successfully, but these errors were encountered: