-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also alpha-sorted, added some unit tests, fixed a small bug or two (eg reset style cache in recomputeGridSize)
- Loading branch information
Brian Vaughn
committed
Dec 14, 2016
1 parent
17d4a61
commit 25293e1
Showing
7 changed files
with
210 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>foo</title> | ||
<style type="text/css"> | ||
body, html, #mount { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; | ||
font-size: 12px; | ||
} | ||
* { | ||
box-sizing: border-box; | ||
} | ||
.item { | ||
height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
border: 1px solid #eee; | ||
} | ||
.item:hover { | ||
background-color: rgba(0, 0, 0, .2); | ||
} | ||
.hoveredItem { | ||
background-color: rgba(0, 0, 0, .1); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="mount"></div> | ||
|
||
<script src="utils.js"></script> | ||
<script src="helper.js"></script> | ||
<script> | ||
loadReact(); | ||
loadScriptsAndStyles('render-counters.js'); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
const { Component } = React | ||
const { shallowCompare } = React.addons | ||
const { AutoSizer, List } = ReactVirtualized | ||
|
||
class ListExample extends Component { | ||
render() { | ||
return React.createElement( | ||
AutoSizer, | ||
null, | ||
({ height, width }) => React.createElement(List, { | ||
height: height, | ||
overscanRowCount: 0, | ||
rowCount: 1000, | ||
rowHeight: 30, | ||
rowRenderer: this._rowRenderer, | ||
width: width | ||
}) | ||
); | ||
} | ||
|
||
shouldComponentUpdate(nextProps, nextState) { | ||
return shallowCompare(this, nextProps, nextState); | ||
} | ||
|
||
_rowRenderer({ index, isScrolling, key, style }) { | ||
return React.createElement(Row, { | ||
index: index, | ||
key: key, | ||
style: style | ||
}); | ||
} | ||
} | ||
|
||
class Row extends Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
|
||
this.state = { | ||
counter: 0 | ||
}; | ||
|
||
this._renderCount = 0; | ||
} | ||
|
||
render() { | ||
this._renderCount++; | ||
|
||
const { counter } = this.state; | ||
const { index, style } = this.props; | ||
|
||
return React.createElement( | ||
'div', | ||
{ | ||
onClick: () => { | ||
this.setState(state => { | ||
counter: state.counter++; | ||
}); | ||
}, | ||
style: style | ||
}, | ||
'Row ', | ||
index, | ||
', ', | ||
this._renderCount | ||
); | ||
} | ||
|
||
shouldComponentUpdate(nextProps, nextState) { | ||
return shallowCompare(this, nextProps, nextState); | ||
} | ||
} | ||
|
||
ReactDOM.render( | ||
React.createElement(ListExample), | ||
document.querySelector('#mount') | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters