Skip to content
This repository was archived by the owner on Dec 15, 2018. It is now read-only.
This repository was archived by the owner on Dec 15, 2018. It is now read-only.

Rendering after back/forward inconsistent with push #144

Closed
@dpwrussell

Description

@dpwrussell

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:

  1. Start at page 1
  2. Click link (push) to page 2
  3. Click link (push) to page 1

and

  1. Start at page 1
  2. Click link (push) to page 2
  3. Click browser back button or a link using goBack 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, or redux-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 of Child if pressing back from Child to Parent.

      <RouterProvider store={ store }>
        <Layout>

          <Fragment forRoute='/parent'>
            <Parent />
          </Fragment>

          <Fragment forRoute='/child'>
            <Child />
          </Fragment>

        </Layout>
      </RouterProvider>

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions