Logs Panel: Table UI - Logs.tsx clean up mutation in react lifecycle (#78925)

* remove prop mutation in componentWillUnmount
pull/77336/head
Galen Kistler 2 years ago committed by GitHub
parent 5af7b451d0
commit 243c7583c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      public/app/features/explore/Logs/Logs.tsx

@ -174,15 +174,22 @@ class UnthemedLogs extends PureComponent<Props, State> {
if (this.cancelFlippingTimer) { if (this.cancelFlippingTimer) {
window.clearTimeout(this.cancelFlippingTimer); window.clearTimeout(this.cancelFlippingTimer);
} }
// Delete url state on unmount
if (this.props?.panelState?.logs?.columns) { // If we're unmounting logs (e.g. switching to another datasource), we need to remove the table specific panel state, otherwise it will persist in the explore url
delete this.props.panelState.logs.columns; if (
} this.props?.panelState?.logs?.columns ||
if (this.props?.panelState?.logs?.refId) { this.props?.panelState?.logs?.refId ||
delete this.props.panelState.logs.refId; this.props?.panelState?.logs?.labelFieldName
} ) {
if (this.props?.panelState?.logs?.labelFieldName) { dispatch(
delete this.props.panelState.logs.labelFieldName; changePanelState(this.props.exploreId, 'logs', {
...this.props.panelState?.logs,
columns: undefined,
visualisationType: this.state.visualisationType,
labelFieldName: undefined,
refId: undefined,
})
);
} }
} }
updatePanelState = (logsPanelState: Partial<ExploreLogsPanelState>) => { updatePanelState = (logsPanelState: Partial<ExploreLogsPanelState>) => {

Loading…
Cancel
Save