address comments
This commit is contained in:
@@ -288,21 +288,44 @@ describe('FixedSizeGrid', () => {
|
||||
it('should warn about deprecated overscanCount prop', () => {
|
||||
spyOn(console, 'warn');
|
||||
|
||||
const renderer = ReactTestRenderer.create(
|
||||
<FixedSizeGrid {...defaultProps} overscanCount={1} />
|
||||
);
|
||||
expect(console.warn).toHaveBeenCalledTimes(1);
|
||||
expect(console.warn).toHaveBeenLastCalledWith(
|
||||
'The overscanCount prop has been deprecated. ' +
|
||||
'Please use the overscanColumnCount and overscanRowCount props instead.'
|
||||
);
|
||||
|
||||
renderer.update(<FixedSizeGrid {...defaultProps} overscanCount={1} />);
|
||||
|
||||
// But it should only warn once.
|
||||
expect(console.warn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should warn about deprecated overscanRowsCount or overscanColumnsCount prop', () => {
|
||||
spyOn(console, 'warn');
|
||||
|
||||
const renderer = ReactTestRenderer.create(
|
||||
<FixedSizeGrid
|
||||
{...defaultProps}
|
||||
overscanCount={1}
|
||||
overscanRowsCount={1}
|
||||
overscanColumnsCount={1}
|
||||
/>
|
||||
);
|
||||
expect(console.warn).toHaveBeenCalledTimes(1);
|
||||
expect(console.warn).toHaveBeenLastCalledWith(
|
||||
'The overscanCount, overscanColumnsCount and overscanRowsCount props have been deprecated. ' +
|
||||
'The overscanColumnsCount and overscanRowsCount props have been deprecated. ' +
|
||||
'Please use the overscanColumnCount and overscanRowCount props instead.'
|
||||
);
|
||||
|
||||
renderer.update(<FixedSizeGrid {...defaultProps} overscanCount={1} />);
|
||||
renderer.update(
|
||||
<FixedSizeGrid
|
||||
{...defaultProps}
|
||||
overscanRowsCount={1}
|
||||
overscanColumnsCount={1}
|
||||
/>
|
||||
);
|
||||
|
||||
// But it should only warn once.
|
||||
expect(console.warn).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -132,10 +132,12 @@ const defaultItemKey = ({ columnIndex, data, rowIndex }) =>
|
||||
// In DEV mode, this Set helps us only log a warning once per component instance.
|
||||
// This avoids spamming the console every time a render happens.
|
||||
let devWarningsOverscanCount = null;
|
||||
let devWarningsOverscanRowsColumnsCount = null;
|
||||
let devWarningsTagName = null;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
|
||||
devWarningsOverscanCount = new WeakSet();
|
||||
devWarningsOverscanRowsColumnsCount = new WeakSet();
|
||||
devWarningsTagName = new WeakSet();
|
||||
}
|
||||
}
|
||||
@@ -772,21 +774,35 @@ const validateSharedProps = (
|
||||
height,
|
||||
innerTagName,
|
||||
outerTagName,
|
||||
overscanColumnsCount,
|
||||
overscanCount,
|
||||
overscanRowsCount,
|
||||
width,
|
||||
}: Props<any>,
|
||||
{ instance }: State
|
||||
): void => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (
|
||||
typeof overscanCount === 'number' ||
|
||||
typeof overscanColumnsCount === 'number' ||
|
||||
typeof overscanRowsCount === 'number'
|
||||
) {
|
||||
if (typeof overscanCount === 'number') {
|
||||
if (devWarningsOverscanCount && !devWarningsOverscanCount.has(instance)) {
|
||||
devWarningsOverscanCount.add(instance);
|
||||
console.warn(
|
||||
'The overscanCount, overscanColumnsCount and overscanRowsCount props have been deprecated. ' +
|
||||
'The overscanCount prop has been deprecated. ' +
|
||||
'Please use the overscanColumnCount and overscanRowCount props instead.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
typeof overscanColumnsCount === 'number' ||
|
||||
typeof overscanRowsCount === 'number'
|
||||
) {
|
||||
if (
|
||||
devWarningsOverscanRowsColumnsCount &&
|
||||
!devWarningsOverscanRowsColumnsCount.has(instance)
|
||||
) {
|
||||
devWarningsOverscanRowsColumnsCount.add(instance);
|
||||
console.warn(
|
||||
'The overscanColumnsCount and overscanRowsCount props have been deprecated. ' +
|
||||
'Please use the overscanColumnCount and overscanRowCount props instead.'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user