javascript - Preact + TypeScript 不允许我直接调用 h 函数而不是使用 JSX
问题描述
请参阅此最小示例代码:
import { FunctionalComponent, h } from 'preact';
const Text: FunctionalComponent = () => {
const tag = 'div'
const props = {}
const children = 'I am children'
return (
h(tag, props, children)
)
}
它说:Cannot invoke an expression whose type lacks a call signature. Type 'typeof h' has no compatible call signatures.
如果我直接使用 JSX 就可以了:
如何直接使用该h
功能?
解决方案
推荐阅读
- guice - 如何调试 Guice 类/方法拦截器?
- asp.net-core - 检查表中的多个条目 - ASP.NET Core 3.1 和 EFCore
- apache-calcite - 在哪里设置方解石弹性搜索用户名/密码?
- django - 在 Django 中,html 模板中的 for 循环无法正常工作
- python - 在 Pandas DataFrame 中,如何根据字符串前缀将列表转换为多个列表并保持顺序?[Python]
- java - 使用多个字段将对象添加到集合中作为相等比较,以覆盖现有的 equals 和 hashCode 方法
- bash - 如何从 TMUX 会话中完全关闭终端(Ubuntu bash)?
- python - 根据来自另一个数据帧的列值在数据帧中查找一行并对其应用过滤器
- php - 如何使用 phpunit 模拟 Yii@1.1 的 CActiveRecord(避免空属性)?
- android - Android 库字符串覆盖项目字符串