Upgrade react-router-dom to v5.3

This commit is contained in:
Alex Gleason
2022-03-17 20:17:28 -05:00
parent 96398a61f5
commit 1f0341aa2b
53 changed files with 269 additions and 372 deletions

View File

@@ -1,11 +1,9 @@
import PropTypes from 'prop-types';
import React from 'react';
import { withRouter } from 'react-router-dom';
export default class Permalink extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
export default @withRouter
class Permalink extends React.PureComponent {
static propTypes = {
className: PropTypes.string,
@@ -13,6 +11,7 @@ export default class Permalink extends React.PureComponent {
to: PropTypes.string.isRequired,
children: PropTypes.node,
onInterceptClick: PropTypes.func,
history: PropTypes.object,
};
handleClick = e => {
@@ -21,9 +20,9 @@ export default class Permalink extends React.PureComponent {
return;
}
if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
if (this.props.history && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
this.context.router.history.push(this.props.to);
this.props.history.push(this.props.to);
}
}