简体   繁体   English

必须在 className 中使用解构道具分配

[英]Must use destructuring props assignment in className

I've applied ESLint Airbnb standard to my code like:我已将 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
>

I think that I do something bad in the line for Cypress, but how to improve it?我认为我为赛普拉斯做了一些不好的事情,但是如何改进呢?

Your class attribute,您的 class 属性,

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

will expand to something like将扩展到类似

<button class="estimate + 42">

I think you got the string interpolation wrong, try:我认为您的字符串插值错误,请尝试:

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

The problem was also that I two times was trying to get id , I was trying props.id but also:问题还在于我两次尝试获取id ,我在尝试props.id ,但也:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM