Skip to content

Instantly share code, notes, and snippets.

@alexburner
Last active August 9, 2017 21:37
Show Gist options
  • Save alexburner/10d651798d7b5286fd05ec5a3a8c8d40 to your computer and use it in GitHub Desktop.
Save alexburner/10d651798d7b5286fd05ec5a3a8c8d40 to your computer and use it in GitHub Desktop.
// ActivityMapFrame.tsx
componentWillReceiveProps(nextProps: Props) {
// Destroy & re-create with config opts if they've changed
if (this.props.is3D !== nextProps.is3D) {
this.map.destroy();
this.loadMap(nextProps);
return;
}
// Update edges/devices if they've changed
if (
this.props.edges !== nextProps.edges ||
this.props.devicesById !== nextProps.devicesById
) {
this.map.update(nextProps.edges, nextProps.devicesById);
}
// Update theme key if it's changed
if (this.props.themeKey !== nextProps.themeKey) {
this.map.setTheme({ themeKey });
}
}
// ActivityMap.ts
setTheme(themeKey: ThemeKey) {
this.model ...etc
this.drawing ...etc
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment