Skip to content
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

doesnt work with pure render mixin #866

Closed
yocontra opened this issue Feb 24, 2015 · 4 comments
Closed

doesnt work with pure render mixin #866

yocontra opened this issue Feb 24, 2015 · 4 comments

Comments

@yocontra
Copy link
Contributor

since the route is essentially a new form of state the react pure render mixin doesn't work out of the box. i wrote one that does work that could be used instead

'use strict';

var shallowEqual = require('react/lib/shallowEqual');
var lastPath;

module.exports = {
  shouldComponentUpdate: function(nextProps, nextState) {
    // component is route-able
    var routeChanged = this.getPath && didPathChange(this.getPath());
    return routeChanged ||
      !shallowEqual(this.props, nextProps) ||
      !shallowEqual(this.state, nextState);
  }
};

function didPathChange(currPath) {
  var pathChanged = lastPath !== currPath;
  lastPath = currPath;
  return pathChanged;
}

not sure if this is just a documentation item or something you want to put in the repo

@gaearon
Copy link
Contributor

gaearon commented Feb 24, 2015

I believe this to be a duplicate of #470. I currently solve this by having my own mixin where I explicitly subscribe to my own RouterStore so it gets into state.

Really, the underlying issue is React's: facebook/react#2517

@yocontra
Copy link
Contributor Author

cool - didnt get anything when i searched for "pure" but that is def a duplicate. will keep an eye on that

@tajo
Copy link

tajo commented Apr 5, 2015

@CezaryDanielNowak
Copy link

This issue still occours

@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 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

No branches or pull requests

4 participants