Skip to content

avoid unnecessary work #1582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jeffreywescott
Copy link

It seems to me that when someone clicks on a Link, if the current router state is the same as what the resulting router state would be after the Link is done transitioning, we should just disallow the transition to begin with.

This helps to avoid unnecessary flickering, particularly in a flux environment.

if the current state of the router is the same as the destination of the Link, disallow the transition
@agundermann
Copy link
Contributor

This looks similar to how it used to be before (0.x), but it was changed to allow "refreshing" the page when clicking a link to the current page (see #1031 and related).

@ryanflorence
Copy link
Member

yep, we want to be as similar to "normal" routing as possible.

You could maybe avoid the work in a top level component?

<Route component={DontAllowRefresh}>
  {/* the rest of your routes */}
</Route>

class DontAllowRefresh extends React.Component {
  shouldComponentUpdate (nextProps) {
    // do your checking against the location data    
  }
}

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants