Skip to content

Commit

Permalink
Collection.forceUpdate() calls inner CollectionView.forceUpdate()
Browse files Browse the repository at this point in the history
Resolves #568
  • Loading branch information
Brian Vaughn committed Feb 14, 2017
1 parent 77414b6 commit 4fc6999
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions source/Collection/Collection.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,4 +719,19 @@ describe('Collection', () => {
done()
})
})

// See issue #568 for more
it('forceUpdate will also forceUpdate the inner CollectionView', () => {
const cellRenderer = jest.fn()
cellRenderer.mockImplementation(({ key }) => <div key={key} />)

const rendered = render(getMarkup({ cellRenderer }))

expect(cellRenderer).toHaveBeenCalled()

cellRenderer.mockReset()
rendered.forceUpdate()

expect(cellRenderer).toHaveBeenCalled()
})
})
6 changes: 6 additions & 0 deletions source/Collection/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export default class Collection extends PureComponent {
this._setCollectionViewRef = this._setCollectionViewRef.bind(this)
}

forceUpdate () {
if (this._collectionView !== undefined) {
this._collectionView.forceUpdate()
}
}

/** See Collection#recomputeCellSizesAndPositions */
recomputeCellSizesAndPositions () {
this._cellCache = []
Expand Down

0 comments on commit 4fc6999

Please sign in to comment.