@@ -10,6 +10,15 @@ import { inRange } from './utils/eventLevels'
1010import { isSelected } from './utils/selection'
1111
1212class Agenda extends React . Component {
13+ constructor ( props ) {
14+ super ( props )
15+ this . headerRef = React . createRef ( )
16+ this . dateColRef = React . createRef ( )
17+ this . timeColRef = React . createRef ( )
18+ this . contentRef = React . createRef ( )
19+ this . tbodyRef = React . createRef ( )
20+ }
21+
1322 componentDidMount ( ) {
1423 this . _adjustHeader ( )
1524 }
@@ -33,22 +42,22 @@ class Agenda extends React.Component {
3342 < div className = "rbc-agenda-view" >
3443 { events . length !== 0 ? (
3544 < React . Fragment >
36- < table ref = "header" className = "rbc-agenda-table" >
45+ < table ref = { this . headerRef } className = "rbc-agenda-table" >
3746 < thead >
3847 < tr >
39- < th className = "rbc-header" ref = "dateCol" >
48+ < th className = "rbc-header" ref = { this . dateColRef } >
4049 { messages . date }
4150 </ th >
42- < th className = "rbc-header" ref = "timeCol" >
51+ < th className = "rbc-header" ref = { this . timeColRef } >
4352 { messages . time }
4453 </ th >
4554 < th className = "rbc-header" > { messages . event } </ th >
4655 </ tr >
4756 </ thead >
4857 </ table >
49- < div className = "rbc-agenda-content" ref = "content" >
58+ < div className = "rbc-agenda-content" ref = { this . contentRef } >
5059 < table className = "rbc-agenda-table" >
51- < tbody ref = "tbody" >
60+ < tbody ref = { this . tbodyRef } >
5261 { range . map ( ( day , idx ) => this . renderDay ( day , events , idx ) ) }
5362 </ tbody >
5463 </ table >
@@ -155,15 +164,16 @@ class Agenda extends React.Component {
155164 }
156165
157166 _adjustHeader = ( ) => {
158- if ( ! this . refs . tbody ) return
167+ if ( ! this . tbodyRef . current ) return
159168
160- let header = this . refs . header
161- let firstRow = this . refs . tbody . firstChild
169+ let header = this . headerRef . current
170+ let firstRow = this . tbodyRef . current . firstChild
162171
163172 if ( ! firstRow ) return
164173
165174 let isOverflowing =
166- this . refs . content . scrollHeight > this . refs . content . clientHeight
175+ this . contentRef . current . scrollHeight >
176+ this . contentRef . current . clientHeight
167177 let widths = this . _widths || [ ]
168178
169179 this . _widths = [
@@ -172,8 +182,8 @@ class Agenda extends React.Component {
172182 ]
173183
174184 if ( widths [ 0 ] !== this . _widths [ 0 ] || widths [ 1 ] !== this . _widths [ 1 ] ) {
175- this . refs . dateCol . style . width = this . _widths [ 0 ] + 'px'
176- this . refs . timeCol . style . width = this . _widths [ 1 ] + 'px'
185+ this . dateColRef . current . style . width = this . _widths [ 0 ] + 'px'
186+ this . timeColRef . current . style . width = this . _widths [ 1 ] + 'px'
177187 }
178188
179189 if ( isOverflowing ) {
0 commit comments