Deeply compare viewabilityConfigs to avoid triggering invariant unnecessarily
Summary: Currently, modifying a component that renders a FlatLists while Hot Reloading is enabled will trigger an invariant inside FlatList for changing viewabilityConfig on the fly. This happens because it checks object equality between the configs. By checking equality of the config's *properties* instead, we maintain the efficacy of the invariant but keep it from falsely triggering during development. Reviewed By: sahrens Differential Revision: D9466129 fbshipit-source-id: 67149e9e70ad7b2e2584bb7ec03e2dea26ef45e8
This commit is contained in:
parent
d2c27f5bff
commit
122dc37afe
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const deepDiffer = require('deepDiffer');
|
||||||
const MetroListView = require('MetroListView'); // Used as a fallback legacy option
|
const MetroListView = require('MetroListView'); // Used as a fallback legacy option
|
||||||
const React = require('React');
|
const React = require('React');
|
||||||
const View = require('View');
|
const View = require('View');
|
||||||
|
@ -472,7 +473,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||||
'Changing onViewableItemsChanged on the fly is not supported',
|
'Changing onViewableItemsChanged on the fly is not supported',
|
||||||
);
|
);
|
||||||
invariant(
|
invariant(
|
||||||
prevProps.viewabilityConfig === this.props.viewabilityConfig,
|
!deepDiffer(prevProps.viewabilityConfig, this.props.viewabilityConfig),
|
||||||
'Changing viewabilityConfig on the fly is not supported',
|
'Changing viewabilityConfig on the fly is not supported',
|
||||||
);
|
);
|
||||||
invariant(
|
invariant(
|
||||||
|
|
Loading…
Reference in New Issue