Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return foo;
},
events: {
on: (eventName: EventName, handler?: EventHandler | ErrorEventHandler) => {
// let foo: void;
// return foo;
},
off: (eventName: EventName, handler?: EventHandler | ErrorEventHandler) => {
// let foo: void;
// return foo;
}
}
};
// @ts-ignore
Router.router = mockRouter as RouterProps;
// https://github.com/zeit/next.js/issues/5205#issuecomment-422846339
export default class MockNextContext extends React.Component {
static childContextTypes = {
headManager: PropTypes.object,
router: PropTypes.object
};
getChildContext() {
const { headManager, router } = this.props;
return {
headManager: {
updateHead() {},
...headManager
},
router: Object.assign(mockRouter, router)
componentWillUnmount() {
Router.router.events.off("routeChangeComplete", this.trackPageview);
}
componentWillUnmount() {
Router.router.events.off("routeChangeComplete", this.trackPageview);
}
componentDidMount() {
initGa();
this.trackSourceView();
Router.router.events.on("routeChangeComplete", this.trackSourceView);
}
withState('texts', 'onTextChange', () => {
if (!Router.router) return ''
const { query } = Router.router
if (!query.searchTexts) {
return ''
}
return query.searchTexts
}),
graphql(gql`
router: { ...mockedRouter, ...mockRouter }
}
}
render () {
return this.props.children
}
}
MockRouterContext.childContextTypes = {
router: PropTypes.object
}
return MockRouterContext
}
Router.router = mockedRouter
const StorybookRouterFix = withMockRouterContext(mockedRouter)
function MockProjectContext({ children, theme }) {
return (
{children}
)
}
componentDidMount() {
this.sbs = ScrollBar.initAll()
if (window.scrollHandlers) {
window.scrollHandlers.forEach(handler => {
this.sbs[0].addListener(handler)
})
}
this.route = Router.router ? Router.router.pathname : ''
this.forceUpdate()
}