Use props.router instead of context.router, as we are using withRouter

This commit is contained in:
Thibaut Girka 2018-05-23 12:55:31 +02:00
parent e396fbfe3b
commit f86d280fd6
1 changed files with 17 additions and 20 deletions

View File

@ -99,10 +99,6 @@ const keyMap = {
@withRouter @withRouter
export default class UI extends React.Component { export default class UI extends React.Component {
static contextTypes = {
router: PropTypes.object.isRequired,
};
static propTypes = { static propTypes = {
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
children: PropTypes.node, children: PropTypes.node,
@ -113,6 +109,7 @@ export default class UI extends React.Component {
isComposing: PropTypes.bool, isComposing: PropTypes.bool,
hasComposingText: PropTypes.bool, hasComposingText: PropTypes.bool,
location: PropTypes.object, location: PropTypes.object,
router: PropTypes.object,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
dropdownMenuIsOpen: PropTypes.bool, dropdownMenuIsOpen: PropTypes.bool,
}; };
@ -200,7 +197,7 @@ export default class UI extends React.Component {
handleServiceWorkerPostMessage = ({ data }) => { handleServiceWorkerPostMessage = ({ data }) => {
if (data.type === 'navigate') { if (data.type === 'navigate') {
this.context.router.history.push(data.path); this.props.router.history.push(data.path);
} else { } else {
console.warn('Unknown message type:', data.type); console.warn('Unknown message type:', data.type);
} }
@ -306,9 +303,9 @@ export default class UI extends React.Component {
handleHotkeyBack = () => { handleHotkeyBack = () => {
if (window.history && window.history.length === 1) { if (window.history && window.history.length === 1) {
this.context.router.history.push('/'); this.props.router.history.push('/');
} else { } else {
this.context.router.history.goBack(); this.props.router.history.goBack();
} }
} }
@ -318,54 +315,54 @@ export default class UI extends React.Component {
handleHotkeyToggleHelp = () => { handleHotkeyToggleHelp = () => {
if (this.props.location.pathname === '/keyboard-shortcuts') { if (this.props.location.pathname === '/keyboard-shortcuts') {
this.context.router.history.goBack(); this.props.router.history.goBack();
} else { } else {
this.context.router.history.push('/keyboard-shortcuts'); this.props.router.history.push('/keyboard-shortcuts');
} }
} }
handleHotkeyGoToHome = () => { handleHotkeyGoToHome = () => {
this.context.router.history.push('/timelines/home'); this.props.router.history.push('/timelines/home');
} }
handleHotkeyGoToNotifications = () => { handleHotkeyGoToNotifications = () => {
this.context.router.history.push('/notifications'); this.props.router.history.push('/notifications');
} }
handleHotkeyGoToLocal = () => { handleHotkeyGoToLocal = () => {
this.context.router.history.push('/timelines/public/local'); this.props.router.history.push('/timelines/public/local');
} }
handleHotkeyGoToFederated = () => { handleHotkeyGoToFederated = () => {
this.context.router.history.push('/timelines/public'); this.props.router.history.push('/timelines/public');
} }
handleHotkeyGoToDirect = () => { handleHotkeyGoToDirect = () => {
this.context.router.history.push('/timelines/direct'); this.props.router.history.push('/timelines/direct');
} }
handleHotkeyGoToStart = () => { handleHotkeyGoToStart = () => {
this.context.router.history.push('/getting-started'); this.props.router.history.push('/getting-started');
} }
handleHotkeyGoToFavourites = () => { handleHotkeyGoToFavourites = () => {
this.context.router.history.push('/favourites'); this.props.router.history.push('/favourites');
} }
handleHotkeyGoToPinned = () => { handleHotkeyGoToPinned = () => {
this.context.router.history.push('/pinned'); this.props.router.history.push('/pinned');
} }
handleHotkeyGoToProfile = () => { handleHotkeyGoToProfile = () => {
this.context.router.history.push(`/accounts/${me}`); this.props.router.history.push(`/accounts/${me}`);
} }
handleHotkeyGoToBlocked = () => { handleHotkeyGoToBlocked = () => {
this.context.router.history.push('/blocks'); this.props.router.history.push('/blocks');
} }
handleHotkeyGoToMuted = () => { handleHotkeyGoToMuted = () => {
this.context.router.history.push('/mutes'); this.props.router.history.push('/mutes');
} }
render () { render () {