mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 03:16:40 +00:00
We trigger current url history only once the page has been mounted
This commit is contained in:
@@ -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} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user