reactjs - 在组件中设置类型?
问题描述
有人能解释一下这个语法在做什么吗?我没见过太多
type ScrollProps = {
location: Object,
elementID?: string
};
class ScrollMemory extends Component<ScrollProps> {
detectPop: () => void;
url: Map<string, number>;
原始来源
https://github.com/ipatate/react-router-scroll-memory/blob/master/src/ScrollMemory.js
解决方案
类型检查!这是为您的组件设置类型。这反过来将 IntelliSense/Typechecking 添加到您的代码中(如果您的 IDE 支持它)。
您链接的示例使用流。如果您想了解更多信息,请查看https://flow.org/
推荐阅读
- php - 带有 OR 和括号的 MySQL SELECT 查询不起作用
- c - 将十六进制字符 IP 转换为二进制
- spring-mvc - Spring 注解 @NotNull 和 @Size 不起作用
- spring-boot - 如何测试 Gitlab-ci Docker + Spring Boot + Testcontainers + Wkhtmltopdf
- javascript - 跳过按钮 - 如何用另一个功能停止一个功能
- python - 在 geoseries 中访问几何中的行
- javascript - 如何从节点模块导入 PaperJS?
- java - 意图问题:如何使用另一个类“适配器”中的 MainActivity 将数据传递给 SecondActivity
- python - 使用 1 个月和 12 个月的滞后计算 Python 中的动量信号
- html - 尝试重新创建此网页设计但无法拆分网页