简体   繁体   English

如何使用 Typescript 转换与 React

[英]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 &#8457;</a>
        <a className="dropdown-item" href="#!" 
            onClick={() => setMetric(false)}>Celsius &#8451;</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.

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