diff --git a/source/Collection/Collection.jest.js b/source/Collection/Collection.jest.js index 379c4c196..38fa9405b 100644 --- a/source/Collection/Collection.jest.js +++ b/source/Collection/Collection.jest.js @@ -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 }) =>
) + + const rendered = render(getMarkup({ cellRenderer })) + + expect(cellRenderer).toHaveBeenCalled() + + cellRenderer.mockReset() + rendered.forceUpdate() + + expect(cellRenderer).toHaveBeenCalled() + }) }) diff --git a/source/Collection/Collection.js b/source/Collection/Collection.js index a246ac6d8..df293d024 100644 --- a/source/Collection/Collection.js +++ b/source/Collection/Collection.js @@ -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 = []