fix:更新时 treeData 加判断
This commit is contained in:
parent
d91db60e51
commit
101756fa84
|
@ -136,7 +136,7 @@ var Tree = function (_React$Component) {
|
|||
if (selectedKeys) {
|
||||
st.selectedKeys = selectedKeys;
|
||||
}
|
||||
if (nextProps.treeData !== this.props.treeData) {
|
||||
if (nextProps.hasOwnProperty('treeData') && nextProps.treeData !== this.props.treeData) {
|
||||
this.dataChange = true;
|
||||
st.treeData = treeData;
|
||||
}
|
||||
|
@ -1217,7 +1217,7 @@ Tree.propTypes = {
|
|||
openAnimation: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].object]),
|
||||
lazyLoad: _propTypes2["default"].bool,
|
||||
treeData: _propTypes2["default"].array,
|
||||
renderTreeNode: _propTypes2["default"].func
|
||||
renderTreeNodes: _propTypes2["default"].func
|
||||
};
|
||||
|
||||
Tree.defaultProps = {
|
||||
|
|
|
@ -393,12 +393,17 @@ function convertListToTree(treeData, attr, flatTreeKeysMap) {
|
|||
var findParentNode = function findParentNode(node) {
|
||||
var parentKey = node[attr.parendId];
|
||||
if (!resKeysMap.hasOwnProperty(parentKey)) {
|
||||
var key = node.key,
|
||||
title = node.title,
|
||||
children = node.children,
|
||||
otherProps = _objectWithoutProperties(node, ['key', 'title', 'children']);
|
||||
|
||||
var obj = {
|
||||
key: flatTreeKeysMap[parentKey][attr.id],
|
||||
title: flatTreeKeysMap[parentKey][attr.name],
|
||||
children: []
|
||||
};
|
||||
tree.push(obj);
|
||||
tree.push(_extends(obj, _extends({}, otherProps)));
|
||||
resKeysMap[obj.key] = obj;
|
||||
}
|
||||
return flatTreeKeysMap[parentKey];
|
||||
|
|
|
@ -34482,7 +34482,7 @@
|
|||
if (selectedKeys) {
|
||||
st.selectedKeys = selectedKeys;
|
||||
}
|
||||
if (nextProps.treeData !== this.props.treeData) {
|
||||
if (nextProps.hasOwnProperty('treeData') && nextProps.treeData !== this.props.treeData) {
|
||||
this.dataChange = true;
|
||||
st.treeData = treeData;
|
||||
}
|
||||
|
@ -35563,7 +35563,7 @@
|
|||
openAnimation: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object]),
|
||||
lazyLoad: _propTypes2['default'].bool,
|
||||
treeData: _propTypes2['default'].array,
|
||||
renderTreeNode: _propTypes2['default'].func
|
||||
renderTreeNodes: _propTypes2['default'].func
|
||||
};
|
||||
|
||||
Tree.defaultProps = {
|
||||
|
@ -36578,12 +36578,17 @@
|
|||
var findParentNode = function findParentNode(node) {
|
||||
var parentKey = node[attr.parendId];
|
||||
if (!resKeysMap.hasOwnProperty(parentKey)) {
|
||||
var key = node.key,
|
||||
title = node.title,
|
||||
children = node.children,
|
||||
otherProps = _objectWithoutProperties(node, ['key', 'title', 'children']);
|
||||
|
||||
var obj = {
|
||||
key: flatTreeKeysMap[parentKey][attr.id],
|
||||
title: flatTreeKeysMap[parentKey][attr.name],
|
||||
children: []
|
||||
};
|
||||
tree.push(obj);
|
||||
tree.push(_extends(obj, _extends({}, otherProps)));
|
||||
resKeysMap[obj.key] = obj;
|
||||
}
|
||||
return flatTreeKeysMap[parentKey];
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bee-tree",
|
||||
"version": "2.1.0-beta.0",
|
||||
"version": "2.1.0-beta.2",
|
||||
"description": "Tree ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
|
|
@ -93,7 +93,7 @@ class Tree extends React.Component {
|
|||
if (selectedKeys) {
|
||||
st.selectedKeys = selectedKeys;
|
||||
}
|
||||
if(nextProps.treeData !== this.props.treeData){
|
||||
if(nextProps.hasOwnProperty('treeData') && nextProps.treeData !== this.props.treeData){
|
||||
this.dataChange = true;
|
||||
st.treeData = treeData;
|
||||
}
|
||||
|
@ -1128,7 +1128,7 @@ Tree.propTypes = {
|
|||
openAnimation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
||||
lazyLoad: PropTypes.bool,
|
||||
treeData: PropTypes.array,
|
||||
renderTreeNode: PropTypes.func
|
||||
renderTreeNodes: PropTypes.func
|
||||
};
|
||||
|
||||
Tree.defaultProps = {
|
||||
|
|
|
@ -340,12 +340,13 @@ export function convertListToTree(treeData, attr, flatTreeKeysMap) {
|
|||
let findParentNode = (node) => {
|
||||
let parentKey = node[attr.parendId];
|
||||
if (!resKeysMap.hasOwnProperty(parentKey) ) {
|
||||
let { key, title, children, ...otherProps } = node;
|
||||
let obj = {
|
||||
key: flatTreeKeysMap[parentKey][attr.id],
|
||||
title: flatTreeKeysMap[parentKey][attr.name],
|
||||
children: []
|
||||
};
|
||||
tree.push(obj);
|
||||
tree.push(Object.assign(obj, {...otherProps}));
|
||||
resKeysMap[obj.key] = obj;
|
||||
}
|
||||
return flatTreeKeysMap[parentKey];
|
||||
|
|
Loading…
Reference in New Issue