7
7
import './plotsContainer.css' ;
8
8
9
9
// React.
10
- import React , { useEffect , useState } from 'react' ;
10
+ import React , { useEffect } from 'react' ;
11
11
12
12
// Other dependencies.
13
13
import * as DOM from '../../../../../base/browser/dom.js' ;
@@ -66,8 +66,6 @@ export const PlotsContainer = (props: PlotContainerProps) => {
66
66
const plotHeight = historyBottom ? props . height - historyPx : props . height ;
67
67
const plotWidth = historyBottom ? props . width : props . width - historyPx ;
68
68
69
- const [ debounceTimer , setDebounceTimer ] = useState < NodeJS . Timeout | undefined > ( undefined ) ;
70
-
71
69
useEffect ( ( ) => {
72
70
// Ensure the selected plot is visible. We do this so that the history
73
71
// filmstrip automatically scrolls to new plots as they are emitted, or
@@ -86,13 +84,12 @@ export const PlotsContainer = (props: PlotContainerProps) => {
86
84
plotHistory . scrollTop = plotHistory . scrollHeight ;
87
85
}
88
86
}
87
+ } , [ plotHistoryRef ] ) ;
89
88
89
+ useEffect ( ( ) => {
90
90
// Propagate current render settings. Use a debouncer to avoid excessive
91
91
// messaging to language kernels.
92
- if ( debounceTimer ) {
93
- clearTimeout ( debounceTimer ) ;
94
- }
95
- setDebounceTimer ( setTimeout ( ( ) => {
92
+ const debounceTimer = setTimeout ( ( ) => {
96
93
props . positronPlotsService . setPlotsRenderSettings ( {
97
94
size : {
98
95
width : plotWidth ,
@@ -101,8 +98,10 @@ export const PlotsContainer = (props: PlotContainerProps) => {
101
98
pixel_ratio : DOM . getActiveWindow ( ) . devicePixelRatio ,
102
99
format : PlotRenderFormat . Png , // Currently hard-coded
103
100
} ) ;
104
- } , 500 ) ) ;
105
- } , [ plotWidth , plotHeight , props . positronPlotsService , plotHistoryRef , debounceTimer ] ) ;
101
+ } , 500 ) ;
102
+
103
+ return ( ) => clearTimeout ( debounceTimer ) ;
104
+ } , [ plotWidth , plotHeight , props . positronPlotsService ] ) ;
106
105
107
106
/**
108
107
* Renders either a DynamicPlotInstance (resizable plot), a
0 commit comments