mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 12:16:37 -04:00
26 lines
786 B
JavaScript
26 lines
786 B
JavaScript
import React, { PureComponent } from 'react';
|
|
import { registerComponent, runCallbacks } from 'meteor/vulcan:lib';
|
|
import { withApollo } from 'react-apollo';
|
|
|
|
class RouterHook extends PureComponent {
|
|
constructor(props) {
|
|
super(props);
|
|
this.runOnUpdateCallback(props);
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
this.runOnUpdateCallback(nextProps);
|
|
}
|
|
|
|
runOnUpdateCallback = props => {
|
|
const { currentRoute, client } = props;
|
|
// the first argument is an item to iterate on, needed by vulcan:lib/callbacks
|
|
// note: this item is not used in this specific callback: router.onUpdate
|
|
runCallbacks('router.onUpdate', {}, currentRoute, client.store, client);
|
|
};
|
|
|
|
render() {
|
|
return null;
|
|
}
|
|
}
|
|
registerComponent('RouterHook', RouterHook, withApollo);
|