Skip to content

Instantly share code, notes, and snippets.

@maximgatilin
Last active August 8, 2018 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximgatilin/7d822634fef28501d158aa21c379a89c to your computer and use it in GitHub Desktop.
Save maximgatilin/7d822634fef28501d158aa21c379a89c to your computer and use it in GitHub Desktop.
Bad way to sync redux and URL
import React, { Component} from 'react';
import PropTypes from 'prop-types';
class Example extends Component {
static contextTypes = {
router: PropTypes.object.isRequired
};
onChange = () => {
// PUSH TO URL
this.context.router.push({
pathname: this.context.router.location.pathname,
query: {
...this.context.router.location.query,
date: date
}
});
}
render() {
// render something
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment