react ice tree报错type

Posted zhuangcui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了react ice tree报错type相关的知识,希望对你有一定的参考价值。

线上的tree报了错,connot read ptoperty ‘type‘ of undefined

后面发现 这里有问题,没有判断条件不满足时返回为空,所以会自己返回undefined,导致报错

const loop = (data) => data.map(item => {
        if (item.branchType == 1 || item.branchType == 2 || item.branchType == 3) {
          return <TreeNode
            label={<Fragment>{Icon(item.branchType)}{item.branchSimpleName}</Fragment>}
            key={item.id}
            data={item}
            >
            {item.children && item.children.length > 0 ? loop(item.children) : null}
            </TreeNode>
        } else {
      // 此处加一个返回为空的判断
return ‘‘ } })
{ data && data.length > 0 ? <React.Fragment>
            <Tree
              defaultExpandAll={false}
              autoExpandParent={autoExpandParent}
              draggable={true}
              defaultExpandedKeys={defaultExpandedKeys}
              filterTreeNode={filterTreeNode}
              expandedKeys={expandedKeys}
              onExpand={this.handleExpand}
              onSelect={this.treeNodeonRightClick}
              animation={true}
              selectedKeys={selectedKeys}
              showLine
              >
              {loop([...data])}
            </Tree>
          </React.Fragment> : ‘‘}

 

以上是关于react ice tree报错type的主要内容,如果未能解决你的问题,请参考以下文章

已解决在react+ts中 atnd 用 upload 组件报错Failed to execute ‘readAsArrayBuffer,param 1 is notof type Blob(代码片段

SpringBoot启动报错“Consider defining a bean of type ‘xxx.mapper.UserMapper‘ in your configuration.“(代码片段

Failed to convert property value of type ‘java.lang.String‘ to required type ‘int‘ for property(代码片段

SpringBoot中表单提交报错“Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported“(代码片段

报错“Field pet in XXX.HelloController required a bean of type ‘XXX.Pet‘ that could not be found.“(代码片段

vue element-ui typescript tree报错 === Property 'getCheckedNodes' does not exist on type '