Helmet: wrap withRouter, probably fix page title getting stuck

This commit is contained in:
Alex Gleason 2021-10-12 16:22:44 -05:00
parent b343a403e8
commit f6b1bca574
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 19 additions and 16 deletions

View file

@ -1,6 +1,7 @@
import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';
import { Helmet } from'react-helmet';
import { getSettings } from 'soapbox/actions/settings';
import sourceCode from 'soapbox/utils/code';
@ -54,4 +55,4 @@ class SoapboxHelmet extends React.Component {
}
export default connect(mapStateToProps)(SoapboxHelmet);
export default withRouter(connect(mapStateToProps)(SoapboxHelmet));

View file

@ -141,22 +141,24 @@ class SoapboxMount extends React.PureComponent {
return (
<IntlProvider locale={locale} messages={this.state.messages}>
<ErrorBoundary>
<Helmet>
<body className={bodyClass} />
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
{customCss && customCss.map(css => (
<link rel='stylesheet' href={css} key={css} />
))}
<meta name='theme-color' content={this.props.brandColor} />
</Helmet>
<BrowserRouter basename={FE_SUBDIRECTORY}>
<ScrollContext shouldUpdateScroll={this.shouldUpdateScroll}>
<Switch>
{!me && <Route exact path='/' component={PublicLayout} />}
<Route exact path='/about/:slug?' component={PublicLayout} />
<Route path='/' component={UI} />
</Switch>
</ScrollContext>
<>
<Helmet>
<body className={bodyClass} />
{themeCss && <style id='theme' type='text/css'>{`:root{${themeCss}}`}</style>}
{customCss && customCss.map(css => (
<link rel='stylesheet' href={css} key={css} />
))}
<meta name='theme-color' content={this.props.brandColor} />
</Helmet>
<ScrollContext shouldUpdateScroll={this.shouldUpdateScroll}>
<Switch>
{!me && <Route exact path='/' component={PublicLayout} />}
<Route exact path='/about/:slug?' component={PublicLayout} />
<Route path='/' component={UI} />
</Switch>
</ScrollContext>
</>
</BrowserRouter>
</ErrorBoundary>
</IntlProvider>