[英]How to use Typescript Transform with React
I have a component in my React app that requires me using the style transform
property.我的 React 应用程序中有一个组件需要我使用
style transform
属性。 When I did so, my component added a reference to Typescript Transform
and now I get the following warning when I compile my app:当我这样做时,我的组件添加了对
Typescript Transform
的引用,现在我在编译我的应用程序时收到以下警告:
./node_modules/typescript/lib/typescript.js
Critical dependency: the request of a dependency is an expression
Here is the reference at the top of my component:这是我的组件顶部的参考:
import { transform } from "typescript";
And here is part of my component in question:这是我有问题的组件的一部分:
<div className={`dropdown-menu dropdown-menu-right border py-0 ${isVisible && " show"}`}
style={{position: "absolute", transform: "translate3d(584px, 39px, 0px)",
top:0, left:0, willChange: transform}}>
<div className="bg-white py-2">
<span className="dropdown-item">Display temp in</span>
<div className="dropdown-divider"></div>
<a className="dropdown-item" href="#!"
onClick={() => setMetric(true)}>Fahrenheit ℉</a>
<a className="dropdown-item" href="#!"
onClick={() => setMetric(false)}>Celsius ℃</a>
</div>
</div>
Specifically: transform: "translate3d(584px, 39px, 0px)"
in my style
prop.具体来说:在我的
style
道具中transform: "translate3d(584px, 39px, 0px)"
。
I am not exactly sure why this is happening.我不确定为什么会这样。 Do I even need
Typescript
for this?我什至需要
Typescript
吗? If so how should solve this issue?如果是这样应该如何解决这个问题?
willChange
css attribute value has to be a string: willChange
8CBA22E28EB17B5F5C6AE2A266AZ 属性值必须是字符串:
willChange: "transform"
Remove this line: import { transform } from "typescript";
删除这一行:
import { transform } from "typescript";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.