Skip to content
Prev Previous commit
Next Next commit
add additional check to avoid some bugs
  • Loading branch information
AllenFang committed Sep 17, 2017
commit 2ecf6feaa7ebf6fa24899232776f635da7346d6b
4 changes: 4 additions & 0 deletions packages/react-bootstrap-table2/src/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ Row.propTypes = {
columns: PropTypes.array.isRequired
};

Row.defaultProps = {
editable: true
};

export default Row;
2 changes: 1 addition & 1 deletion packages/react-bootstrap-table2/src/store/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Store {

edit(rowId, dataField, newValue) {
const row = this.getRowByRowId(rowId);
_.set(row, dataField, newValue);
if (row) _.set(row, dataField, newValue);
}

get() {
Expand Down
5 changes: 3 additions & 2 deletions packages/react-bootstrap-table2/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ function get(target, field) {
return result;
}

function set(target, field, value) {
function set(target, field, value, safe = false) {
const pathArray = splitNested(field);
let level = 0;
pathArray.reduce((a, b) => {
level += 1;
if (typeof a[b] === 'undefined' && level !== pathArray.length) {
if (typeof a[b] === 'undefined') {
if (!safe) throw new Error(`${a}.${b} is undefined`);
a[b] = {};
return a[b];
}
Expand Down