diff --git a/app/javascript/flavours/glitch/components/column_back_button.jsx b/app/javascript/flavours/glitch/components/column_back_button.jsx
index 5a11a3d5ea..0562fae29b 100644
--- a/app/javascript/flavours/glitch/components/column_back_button.jsx
+++ b/app/javascript/flavours/glitch/components/column_back_button.jsx
@@ -4,26 +4,25 @@ import { createPortal } from 'react-dom';
import { FormattedMessage } from 'react-intl';
-import { Icon } from 'flavours/glitch/components/icon';
+import { withRouter } from 'react-router-dom';
+import { Icon } from 'flavours/glitch/components/icon';
+import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
-export default class ColumnBackButton extends PureComponent {
-
- static contextTypes = {
- router: PropTypes.object,
- };
+class ColumnBackButton extends PureComponent {
static propTypes = {
multiColumn: PropTypes.bool,
+ ...WithRouterPropTypes,
};
handleClick = () => {
- const { router } = this.context;
+ const { history } = this.props;
- if (router.history.location?.state?.fromMastodon) {
- router.history.goBack();
+ if (history.location?.state?.fromMastodon) {
+ history.goBack();
} else {
- router.history.push('/');
+ history.push('/');
}
};
@@ -57,3 +56,5 @@ export default class ColumnBackButton extends PureComponent {
}
}
+
+export default withRouter(ColumnBackButton);
diff --git a/app/javascript/flavours/glitch/components/column_back_button_slim.jsx b/app/javascript/flavours/glitch/components/column_back_button_slim.jsx
index 7b3bac45f9..4e4185387d 100644
--- a/app/javascript/flavours/glitch/components/column_back_button_slim.jsx
+++ b/app/javascript/flavours/glitch/components/column_back_button_slim.jsx
@@ -1,25 +1,27 @@
-import PropTypes from 'prop-types';
import { PureComponent } from 'react';
import { FormattedMessage } from 'react-intl';
+import { withRouter } from 'react-router-dom';
+
import { Icon } from 'flavours/glitch/components/icon';
+import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
-export default class ColumnBackButtonSlim extends PureComponent {
+class ColumnBackButtonSlim extends PureComponent {
- static contextTypes = {
- router: PropTypes.object,
+ static propTypes = {
+ ...WithRouterPropTypes,
};
handleClick = () => {
- const { router } = this.context;
+ const { location, history } = this.props;
// Check if there is a previous page in the app to go back to per https://stackoverflow.com/a/70532858/9703201
// When upgrading to V6, check `location.key !== 'default'` instead per https://github.com/remix-run/history/blob/main/docs/api-reference.md#location
- if (router.route.location.key) {
- router.history.goBack();
+ if (location.key) {
+ history.goBack();
} else {
- router.history.push('/');
+ history.push('/');
}
};
@@ -35,3 +37,5 @@ export default class ColumnBackButtonSlim extends PureComponent {
}
}
+
+export default withRouter(ColumnBackButtonSlim);
diff --git a/app/javascript/flavours/glitch/components/column_header.jsx b/app/javascript/flavours/glitch/components/column_header.jsx
index 8a68036e9c..fa13f181d0 100644
--- a/app/javascript/flavours/glitch/components/column_header.jsx
+++ b/app/javascript/flavours/glitch/components/column_header.jsx
@@ -5,8 +5,10 @@ import { createPortal } from 'react-dom';
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';
import classNames from 'classnames';
+import { withRouter } from 'react-router-dom';
-import { Icon } from 'flavours/glitch/components/icon';
+import { Icon } from 'flavours/glitch/components/icon';
+import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
const messages = defineMessages({
show: { id: 'column_header.show_settings', defaultMessage: 'Show settings' },
@@ -18,7 +20,6 @@ const messages = defineMessages({
class ColumnHeader extends PureComponent {
static contextTypes = {
- router: PropTypes.object,
identity: PropTypes.object,
};
@@ -38,6 +39,7 @@ class ColumnHeader extends PureComponent {
onClick: PropTypes.func,
appendContent: PropTypes.node,
collapseIssues: PropTypes.bool,
+ ...WithRouterPropTypes,
};
state = {
@@ -63,12 +65,12 @@ class ColumnHeader extends PureComponent {
};
handleBackClick = () => {
- const { router } = this.context;
+ const { history } = this.props;
- if (router.history.location?.state?.fromMastodon) {
- router.history.goBack();
+ if (history.location?.state?.fromMastodon) {
+ history.goBack();
} else {
- router.history.push('/');
+ history.push('/');
}
};
@@ -78,15 +80,14 @@ class ColumnHeader extends PureComponent {
handlePin = () => {
if (!this.props.pinned) {
- this.context.router.history.replace('/');
+ this.props.history.replace('/');
}
this.props.onPin();
};
render () {
- const { router } = this.context;
- const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues } = this.props;
+ const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues, history } = this.props;
const { collapsed, animating } = this.state;
const wrapperClassName = classNames('column-header__wrapper', {
@@ -129,7 +130,7 @@ class ColumnHeader extends PureComponent {
pinButton = ;
}
- if (!pinned && ((multiColumn && router.history.location?.state?.fromMastodon) || showBackButton)) {
+ if (!pinned && ((multiColumn && history.location?.state?.fromMastodon) || showBackButton)) {
backButton = (