必须在 className 中使用 destructuring props 赋值

Must use destructuring props assignment in className

我已经将 ESLint Airbnb 标准应用到我的代码中,例如:

<Button
  ref={anchorRef}
  aria-controls={open ? 'menu-list-grow' : undefined}
  aria-haspopup="true"
  onClick={handleToggle}
  className={`estimate + ${props.id}`} // for purpose of Cypress
>

我觉得我在Cypress的线路上做的不好,请问如何改进呢?

你的 class 属性,

className={`estimate + ${props.id}`}

将扩展为

<button class="estimate + 42">

我认为你的字符串插值有误,试试:

className={`estimate${props.id}`}

问题还在于我两次试图获得 id,我尝试了 props.id 但还:

  const {
    deleteEstimate /* eslint-disable-line no-shadow */,
    downloadReport /* eslint-disable-line no-shadow */,
    setNotification,
    id,
    name,
    tableRow,
  } = props;