当子组件向父组件传值,但是父组件中是用tab标签来切换试时候会报childRef.current.iocList is not a function
iocList不是一个方法,解决方案如下:
childRefIntel .current && childRefIntel .current.iocList() // 进行判空处理
父组件
function AlarmMessage () {
const childRef = useRef();
const childRefFile = useRef();
const childRefIntel = useRef();
// 切换面板获取key
const onChangeActive = (activeKey) => {
if (activeKey === ‘1’) {
childRef.current.flowListClick()
} else if (activeKey === ‘2’) {
childRefFile.current && childRefFile.current.fileListClick()
} else {
childRefIntel .current && childRefIntel .current.iocList()
}
}
}