From 908b457dec622c9e9c127c224d10ce4797b03a17 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 16 Feb 2020 17:28:24 -0800 Subject: [PATCH] fix: Use alternative redirect method (#1176) --- app/components/Editor/Editor.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/components/Editor/Editor.js b/app/components/Editor/Editor.js index 3a6975c7b..d8623ac43 100644 --- a/app/components/Editor/Editor.js +++ b/app/components/Editor/Editor.js @@ -1,6 +1,6 @@ // @flow import * as React from 'react'; -import { Redirect } from 'react-router-dom'; +import { withRouter, type RouterHistory } from 'react-router-dom'; import { observable } from 'mobx'; import { observer } from 'mobx-react'; import { lighten } from 'polished'; @@ -20,6 +20,7 @@ type Props = { readOnly?: boolean, grow?: boolean, disableEmbeds?: boolean, + history: RouterHistory, forwardedRef: React.Ref, ui: UiStore, }; @@ -54,11 +55,7 @@ class Editor extends React.Component { } } - // protect against redirecting back to the same place - const currentLocation = window.location.pathname + window.location.hash; - if (currentLocation !== navigateTo) { - this.redirectTo = navigateTo; - } + this.props.history.push(navigateTo); } else { window.open(href, '_blank'); } @@ -85,8 +82,6 @@ class Editor extends React.Component { }; render() { - if (this.redirectTo) return ; - return ( @@ -285,7 +280,9 @@ const EditorTooltip = ({ children, ...props }) => ( ); -export default withTheme( - // $FlowIssue - https://github.com/facebook/flow/issues/6103 - React.forwardRef((props, ref) => ) +export default withRouter( + withTheme( + // $FlowIssue - https://github.com/facebook/flow/issues/6103 + React.forwardRef((props, ref) => ) + ) );