2017-12-17 17:42:06 +09:00
|
|
|
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);
|
2017-12-17 20:59:26 +09:00
|
|
|
this.runOnUpdateCallback(props);
|
2017-12-17 17:42:06 +09:00
|
|
|
}
|
2017-12-17 20:59:26 +09:00
|
|
|
|
2017-12-17 17:42:06 +09:00
|
|
|
componentWillReceiveProps(nextProps) {
|
2017-12-17 20:59:26 +09:00
|
|
|
this.runOnUpdateCallback(nextProps);
|
|
|
|
}
|
|
|
|
|
|
|
|
runOnUpdateCallback = props => {
|
|
|
|
const { currentRoute, client } = props;
|
2017-12-17 17:42:06 +09:00
|
|
|
// 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);
|
2017-12-17 20:59:26 +09:00
|
|
|
};
|
|
|
|
|
2017-12-17 17:42:06 +09:00
|
|
|
render() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
registerComponent('RouterHook', RouterHook, withApollo);
|