我正在寻找一种使用Flow / React / ReactDOM的标准方法,以验证字符串是有效的html元素类型。
我在那里使用率达99%
const generateComponent = (ComponentString: $Keys<$JSXIntrinsics>, styleObject) => {
return <ComponentString foo="bar" />
}
const ValidComponent = generateComponent('div');
const ShouldThrowErrorComponent = generateComponent('divv');
但是流程的“ catchall”字符串使任何字符串成为有效的html元素。
必须使用打字稿/流来实现这一点,对吧?
我的目标是避免编写自己的自定义列表,例如this
而是使用已建立的库,例如this
但没有行271 [string]: ReactDOM$HTMLElementJSXIntrinsic,
破坏了显式检查