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) => ) + ) );