mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
fix #735
This commit is contained in:
parent
c01f45a719
commit
bf0c5c43a2
3
packages/react-bootstrap-table2/src/cell.js
vendored
3
packages/react-bootstrap-table2/src/cell.js
vendored
@ -23,7 +23,10 @@ class Cell extends eventDelegater(Component) {
|
||||
|
||||
if (shouldUpdate) return true;
|
||||
|
||||
// if (nextProps.formatter)
|
||||
|
||||
shouldUpdate =
|
||||
nextProps.column.formatter ? !_.isEqual(this.props.row, nextProps.row) : false ||
|
||||
this.props.column.hidden !== nextProps.column.hidden ||
|
||||
this.props.rowIndex !== nextProps.rowIndex ||
|
||||
this.props.columnIndex !== nextProps.columnIndex ||
|
||||
|
||||
@ -218,6 +218,47 @@ describe('Cell', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when props.row is change', () => {
|
||||
describe('and column.formatter is enable', () => {
|
||||
const column = { dataField: 'name', text: 'Product Name', formatter: () => 123 };
|
||||
beforeEach(() => {
|
||||
props = {
|
||||
row,
|
||||
columnIndex: 1,
|
||||
rowIndex: 1,
|
||||
tabIndex: 5,
|
||||
column
|
||||
};
|
||||
wrapper = shallow(
|
||||
<Cell { ...props } />);
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
nextProps = { ...props, row: { ...row, alert: 'test' } };
|
||||
expect(wrapper.instance().shouldComponentUpdate(nextProps)).toBe(true);
|
||||
});
|
||||
});
|
||||
describe('but column.formatter is disable', () => {
|
||||
const column = { dataField: 'name', text: 'Product Name' };
|
||||
beforeEach(() => {
|
||||
props = {
|
||||
row,
|
||||
columnIndex: 1,
|
||||
rowIndex: 1,
|
||||
tabIndex: 5,
|
||||
column
|
||||
};
|
||||
wrapper = shallow(
|
||||
<Cell { ...props } />);
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
nextProps = { ...props, row: { ...row, alert: 'test' } };
|
||||
expect(wrapper.instance().shouldComponentUpdate(nextProps)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('if column.isDummyField is true', () => {
|
||||
describe('when content is change', () => {
|
||||
const column = { dataField: '', text: 'Product Name', isDummyField: true };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user