File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ export class ChatList extends Component {
2020
2121 render ( ) {
2222 return (
23- < div className = { classNames ( 'rce-container-clist' , this . props . className ) } >
23+ < div
24+ ref = { this . props . cmpRef }
25+ className = { classNames ( 'rce-container-clist' , this . props . className ) } >
2426 {
2527 this . props . dataSource . map ( ( x , i ) => (
2628 < ChatItem
Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ export class MessageList extends Component {
1515 }
1616
1717 componentDidUpdate ( ) {
18- var e = this . refs . mlist ;
18+ var e = this . mlistRef ;
19+ if ( ! e )
20+ return ;
21+
1922 var bottom = this . getBottom ( e ) ;
2023 if ( this . props . toBottomHeight === '100%' || bottom < this . props . toBottomHeight ) {
2124 // scroll to bottom
@@ -29,7 +32,7 @@ export class MessageList extends Component {
2932
3033 componentWillReceiveProps ( ) {
3134 this . setState ( {
32- scrollBottom : this . getBottom ( this . refs . mlist ) ,
35+ scrollBottom : this . getBottom ( this . mlistRef ) ,
3336 } ) ;
3437 }
3538
@@ -62,10 +65,16 @@ export class MessageList extends Component {
6265 this . props . onForwardClick ( item , i , e ) ;
6366 }
6467
68+ loadRef ( ref ) {
69+ this . mlistRef = ref ;
70+ if ( this . props . cmpRef instanceof Function )
71+ this . props . cmpRef ( ref ) ;
72+ }
73+
6574 render ( ) {
6675 return (
6776 < div
68- ref = 'mlist'
77+ ref = { this . loadRef . bind ( this ) }
6978 onScroll = { this . props . onScroll }
7079 className = { classNames ( [ 'rce-container-mlist' , this . props . className ] ) } >
7180 {
You can’t perform that action at this time.
0 commit comments