[英]What is the purpose of types/react and types/react-dom libraries in react?
I am working with react 18 in typescript. However, apart from react and react-dom, I also see types/react and types/react-dom libraries in package.json.我正在 typescript 中使用 React 18。但是,除了 React 和 React-dom 之外,我还在 package.json 中看到了 types/react 和 types/react-dom 库。 What is the purpose of these libraries?
这些图书馆的目的是什么?
The ones with @types prefix are type declaration packages.带有@types 前缀的是类型声明包。
It is most commonly found in React Typescript. As in Typescript, we have to define types of variables.它最常见于 React Typescript。与 Typescript 一样,我们必须定义变量的类型。 So when we use React with Typescript, we use types/react to declare the type of the React library and types/react-dom to declare the type of the React-dom library.
所以当我们使用React with Typescript时,我们使用types/react来声明React库的类型,使用types/react-dom来声明React-dom库的类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.