Javascript React无法识别DOM元素样式的组件上的'isActive'属性
我有下面的Javascript React无法识别DOM元素样式的组件上的'isActive'属性,javascript,css,reactjs,ecmascript-6,styled-components,Javascript,Css,Reactjs,Ecmascript 6,Styled Components,我有下面的svg组件,我在其中传递道具 import React from 'react'; export default (props) => ( <svg {...props}> <path d="M11.5 16.45l6.364-6.364" fillRule="evenodd" /> </svg> ); 我看到以下react错误 警告:React无法识别DOM元素上的isActive属性 我在使
svg
组件,我在其中传递道具
import React from 'react';
export default (props) => (
<svg {...props}>
<path
d="M11.5 16.45l6.364-6.364"
fillRule="evenodd"
/>
</svg>
);
我看到以下react
错误
警告:React无法识别DOM元素上的isActive
属性
我在使用样式化组件时遇到了同样的问题,最后我做了如下工作:
<Icon isactive={isActive.toString()} />
${props =>
props.isactive === 'true' &&
css`
transform: rotate(-180deg);
`};
}
${props=>
props.isactive==='true'&&
css`
变换:旋转(-180度);
`};
}
constyledicon=styled({isActive,…props})=>)`
${props=>
道具&&
css`
变换:旋转(-180度);
`};
`
是一个不太老套的解决方案,它还可以防止不必要地将属性呈现给DOM谢谢!这有点老套,还是你认为这是最好的方法?这里并没有任何明确的解决方案-它有点老套,没有关于如何操作的适当文档…名称
isActive
是否有特定的内容?
<Icon isactive={isActive.toString()} />
${props =>
props.isactive === 'true' &&
css`
transform: rotate(-180deg);
`};
}