Inject react router into content (work-around) (#810)

This commit is contained in:
Jaco Greeff 2019-03-13 13:24:54 +01:00 committed by GitHub
parent 41ef13fe67
commit 7bb5fd0588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@
import { I18nProps } from '@polkadot/ui-app/types';
import { ApiProps } from '@polkadot/ui-api/types';
import { QueueProps } from '@polkadot/ui-app/Status/types';
import { RouteProps } from '../types';
import React from 'react';
import { withRouter } from 'react-router';
@ -57,12 +58,17 @@ class Content extends React.Component<Props> {
);
}
// inject router into component that we are rendering (in some cases react-router does
// not play 100% with styled-components because of the new vs old context usage, this
// is a workaround for that)
const ComponentRouted = (withRouter(Component as any) as any) as React.ComponentType<RouteProps>;
return (
<Wrapper>
<QueueConsumer>
{({ queueAction, stqueue, txqueue }: QueueProps) => (
<>
<Component
<ComponentRouted
basePath={`/${name}`}
location={location}
onStatusChange={queueAction}