使用条件渲染反应调用函数

时间:2021-07-25 13:48:43

标签: reactjs

我想调用一个函数,如果它返回true,则渲染组件

 const checkEmpty =(index) => {
    return !draggable;
  }

{hovered && checkEmpty(index) && <OutlineElement index={index}/>}

语法是否正确我可以在条件中使用 checkEmpty 是否会在悬停为 true 时调用它?

0 个答案:

没有答案