diff --git a/public/components/pages/layer_panel/layer_panel.tsx b/public/components/pages/layer_panel/layer_panel.tsx index 5ab26cd..369e053 100644 --- a/public/components/pages/layer_panel/layer_panel.tsx +++ b/public/components/pages/layer_panel/layer_panel.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import './layers.scss'; import { RootReducer } from '../../../reducer/root_reducer'; import { AnyAction, bindActionCreators, Dispatch } from 'redux'; @@ -17,6 +17,7 @@ interface LayerPanelProps { setLayerAction: Function; hideDrillDownGraph: Function; hideNodeDetailPanel: Function; + rootReducer: RootReducer; } const mapStateToProps = (state: LayerPanelState) => { @@ -26,6 +27,10 @@ const mapStateToProps = (state: LayerPanelState) => { export function LayerPanelComponent(props: LayerPanelProps) { const [currentLayer, setCurrentLayer] = useState(1); + useEffect(() => { + setCurrentLayer(props.rootReducer.layer.selectedLayer); + }, [props.rootReducer.layer.selectedLayer]); + const changeLayer = (layer: number) => { const { setLayerAction, hideDrillDownGraph, hideNodeDetailPanel } = props; setCurrentLayer(layer);