We trigger current url history only once the page has been mounted

This commit is contained in:
Samy Pesse
2016-10-05 14:22:01 +02:00
parent 83c98cf4d8
commit 805886e4a9
2 changed files with 34 additions and 13 deletions
@@ -19,12 +19,6 @@ const isBrowser = (typeof window !== 'undefined');
* @type {Plugin}
*/
const corePlugin = new Plugin({
activate: (dispatch) => {
dispatch(Navigation.activate());
},
deactivate: (dispatch) => {
dispatch(Navigation.deactivate());
},
reduce: coreReducers,
actions: {
Components, I18n, Navigation
@@ -4,6 +4,39 @@ const { InjectedComponent } = require('../components/InjectedComponent');
const PJAXWrapper = require('../components/PJAXWrapper');
const I18nProvider = require('../components/I18nProvider');
const ContextProvider = require('../components/ContextProvider');
const Navigation = require('../actions/navigation');
const contextShape = require('../shapes/context');
const GitBookApplication = React.createClass({
propTypes: {
context: contextShape
},
componentDidMount() {
const { context } = this.props;
context.dispatch(Navigation.activate());
},
componentWillUnmount() {
const { context } = this.props;
context.dispatch(Navigation.deactivate());
},
render() {
const { context } = this.props;
return (
<ContextProvider context={context}>
<PJAXWrapper>
<I18nProvider>
<InjectedComponent matching={{ role: 'Body' }} />
</I18nProvider>
</PJAXWrapper>
</ContextProvider>
);
}
});
/**
* Render the application for a GitBook context.
@@ -13,13 +46,7 @@ const ContextProvider = require('../components/ContextProvider');
*/
function renderWithContext(context) {
return (
<ContextProvider context={context}>
<PJAXWrapper>
<I18nProvider>
<InjectedComponent matching={{ role: 'Body' }} />
</I18nProvider>
</PJAXWrapper>
</ContextProvider>
<GitBookApplication context={context} />
);
}