1
1
import * as React from 'react' ;
2
2
import { Event } from '@theia/core/lib/common/event' ;
3
3
import { DisposableCollection } from '@theia/core/lib/common/disposable' ;
4
- import { FixedSizeList as List } from 'react-window' ;
5
- import AutoSizer from 'react-virtualized-auto-sizer' ;
4
+ import { areEqual , FixedSizeList as List } from 'react-window' ;
6
5
import { MonitorModel } from './monitor-model' ;
7
6
import { MonitorConnection } from './monitor-connection' ;
8
7
import dateFormat = require( 'dateformat' ) ;
@@ -32,29 +31,23 @@ export class SerialMonitorOutput extends React.Component<
32
31
33
32
render ( ) : React . ReactNode {
34
33
return (
35
- < div style = { { height : '100%' } } >
36
- < AutoSizer >
37
- { ( { height, width } ) => (
38
- < List
39
- className = "serial-monitor-messages"
40
- height = { height }
41
- itemData = {
42
- {
43
- lines : this . state . lines ,
44
- timestamp : this . state . timestamp ,
45
- } as any
46
- }
47
- itemCount = { this . state . lines . length }
48
- itemSize = { 20 }
49
- width = { width }
50
- ref = { this . listRef }
51
- onItemsRendered = { this . scrollToBottom }
52
- >
53
- { Row }
54
- </ List >
55
- ) }
56
- </ AutoSizer >
57
- </ div >
34
+ < List
35
+ className = "serial-monitor-messages"
36
+ height = { this . props . height }
37
+ itemData = {
38
+ {
39
+ lines : this . state . lines ,
40
+ timestamp : this . state . timestamp ,
41
+ } as any
42
+ }
43
+ itemCount = { this . state . lines . length }
44
+ itemSize = { 18 }
45
+ width = { '100%' }
46
+ ref = { this . listRef }
47
+ onItemsRendered = { this . scrollToBottom }
48
+ >
49
+ { Row }
50
+ </ List >
58
51
) ;
59
52
}
60
53
@@ -105,7 +98,7 @@ export class SerialMonitorOutput extends React.Component<
105
98
} ) . bind ( this ) ;
106
99
}
107
100
108
- const Row = ( {
101
+ const _Row = ( {
109
102
index,
110
103
style,
111
104
data,
@@ -128,12 +121,14 @@ const Row = ({
128
121
null
129
122
) ;
130
123
} ;
124
+ const Row = React . memo ( _Row , areEqual ) ;
131
125
132
126
export namespace SerialMonitorOutput {
133
127
export interface Props {
134
128
readonly monitorModel : MonitorModel ;
135
129
readonly monitorConnection : MonitorConnection ;
136
130
readonly clearConsoleEvent : Event < void > ;
131
+ readonly height : number ;
137
132
}
138
133
139
134
export interface State {
0 commit comments