File tree Expand file tree Collapse file tree 4 files changed +53
-5
lines changed Expand file tree Collapse file tree 4 files changed +53
-5
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const ScrollStyle = {
19
19
overflowAnchor : 'none' ,
20
20
} ;
21
21
22
- type RenderFunc < T > = (
22
+ export type RenderFunc < T > = (
23
23
item : T ,
24
24
index : number ,
25
25
props : { style : React . CSSProperties } ,
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import OriginList from './List' ;
3
+ import Filler from './Filler' ;
4
+
5
+ class List < T > extends OriginList < T > {
6
+ render ( ) {
7
+ const {
8
+ style,
9
+ component : Component = 'div' ,
10
+ height,
11
+ itemHeight,
12
+ data,
13
+ children,
14
+ itemKey,
15
+ onSkipRender,
16
+ ...restProps
17
+ } = this . props ;
18
+
19
+ return (
20
+ < Component style = { { ...style , height } } { ...restProps } >
21
+ < Filler height = { height } > { this . renderChildren ( data , 0 , children ) } </ Filler >
22
+ </ Component >
23
+ ) ;
24
+ }
25
+ }
26
+
27
+ export default List ;
Original file line number Diff line number Diff line change @@ -79,10 +79,6 @@ export function getElementScrollPercentage(element: HTMLElement | null) {
79
79
* But if not provided, downgrade to `findDOMNode` to get the real dom element.
80
80
*/
81
81
export function getNodeHeight ( node : HTMLElement ) {
82
- if ( ! node ) {
83
- return 0 ;
84
- }
85
-
86
82
return findDOMNode ( node ) . offsetHeight ;
87
83
}
88
84
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { mount } from 'enzyme' ;
3
+ import MockList from '../src/mock' ;
4
+ import Filler from '../src/Filler' ;
5
+
6
+ describe ( 'MockList' , ( ) => {
7
+ it ( 'correct render' , ( ) => {
8
+ const wrapper = mount (
9
+ < MockList data = { [ 0 , 1 , 2 ] } itemKey = { id => id } >
10
+ { id => < span > { id } </ span > }
11
+ </ MockList > ,
12
+ ) ;
13
+
14
+ expect ( wrapper . find ( Filler ) . length ) . toBeTruthy ( ) ;
15
+
16
+ for ( let i = 0 ; i < 3 ; i += 1 ) {
17
+ expect (
18
+ wrapper
19
+ . find ( 'span' )
20
+ . at ( i )
21
+ . key ( ) ,
22
+ ) . toBe ( String ( i ) ) ;
23
+ }
24
+ } ) ;
25
+ } ) ;
You can’t perform that action at this time.
0 commit comments