From e46d83762d96c0bb95497635058e9ec81a219012 Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sun, 7 Jan 2018 14:02:50 +0800 Subject: [PATCH] fix EditingCell liftcycle bug --- packages/react-bootstrap-table2-editor/src/wrapper.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/react-bootstrap-table2-editor/src/wrapper.js b/packages/react-bootstrap-table2-editor/src/wrapper.js index 1ae500f..97138d4 100644 --- a/packages/react-bootstrap-table2-editor/src/wrapper.js +++ b/packages/react-bootstrap-table2-editor/src/wrapper.js @@ -7,8 +7,9 @@ import { CLICK_TO_CELL_EDIT, DBCLICK_TO_CELL_EDIT } from './const'; export default ( Base, { _, remoteResolver } -) => - class CellEditWrapper extends remoteResolver(Component) { +) => { + let EditingCell; + return class CellEditWrapper extends remoteResolver(Component) { static propTypes = { options: PropTypes.shape({ mode: PropTypes.oneOf([CLICK_TO_CELL_EDIT, DBCLICK_TO_CELL_EDIT]).isRequired, @@ -24,6 +25,7 @@ export default ( constructor(props) { super(props); + EditingCell = props.cellEdit.editingCellFactory(_); this.startEditing = this.startEditing.bind(this); this.escapeEditing = this.escapeEditing.bind(this); this.completeEditing = this.completeEditing.bind(this); @@ -104,7 +106,7 @@ export default ( const { isDataChanged, ...stateRest } = this.state; const { cellEdit: { - options: { nonEditableRows, ...optionsRest }, + options: { nonEditableRows, errorMessage, ...optionsRest }, editingCellFactory, ...cellEditRest } @@ -113,8 +115,8 @@ export default ( ...optionsRest, ...cellEditRest, ...stateRest, + EditingCell, nonEditableRows: _.isDefined(nonEditableRows) ? nonEditableRows() : [], - EditingCell: editingCellFactory(_), onStart: this.startEditing, onEscape: this.escapeEditing, onUpdate: this.handleCellUpdate @@ -130,3 +132,4 @@ export default ( ); } }; +};