Skip to content

Commit e4e9ae9

Browse files
author
Brian Vaughn
committed
Check for frozen style object before List modifies row-style
Resolves bvaughn#556
1 parent ebb7f58 commit e4e9ae9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

source/List/List.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,17 @@ export default class List extends Component {
158158
_cellRenderer ({ rowIndex, style, ...rest }) {
159159
const { rowRenderer } = this.props
160160

161-
// By default, List cells should be 100% width.
162-
// This prevents them from flowing under a scrollbar (if present).
163-
style.width = '100%'
161+
// TRICKY The style object is sometimes cached by Grid.
162+
// This prevents new style objects from bypassing shallowCompare().
163+
// However as of React 16, style props are auto-frozen (at least in dev mode)
164+
// Check to make sure we can still modify the style before proceeding.
165+
// https://github.com/facebook/react/commit/977357765b44af8ff0cfea327866861073095c12#commitcomment-20648713
166+
const { writable } = Object.getOwnPropertyDescriptor(style, 'width')
167+
if (writable) {
168+
// By default, List cells should be 100% width.
169+
// This prevents them from flowing under a scrollbar (if present).
170+
style.width = '100%'
171+
}
164172

165173
return rowRenderer({
166174
index: rowIndex,

0 commit comments

Comments
 (0)