Javascript react typescript将dom构造函数作为参数发送 界面道具{ 元素:new()=>React.Component; } C类扩展了React.PureComponent{ 建造师(道具:道具){ 超级(道具); this.handleClick=this.handleClick.bind(this); } public render():JSX.Element{ 回来 {this.props.children} ; } } 函数foo():JSX.Element{ 回来 }
我希望Javascript react typescript将dom构造函数作为参数发送 界面道具{ 元素:new()=>React.Component; } C类扩展了React.PureComponent{ 建造师(道具:道具){ 超级(道具); this.handleClick=this.handleClick.bind(this); } public render():JSX.Element{ 回来 {this.props.children} ; } } 函数foo():JSX.Element{ 回来 },javascript,reactjs,typescript,composition,Javascript,Reactjs,Typescript,Composition,我希望foo呈现tr-dom元素,但我在引用tr构造函数时遇到问题。记住TypeScript是javascript的超集。因此,您将以相同的方式创建tr元素 interface Props{ element: new() => React.Component<{}, {}>; } class C extends React.PureComponent<Props, {}> { constructor(props: Props<T>) {
foo
呈现tr-dom元素,但我在引用tr构造函数时遇到问题。记住TypeScript是javascript的超集。因此,您将以相同的方式创建tr元素
interface Props{
element: new() => React.Component<{}, {}>;
}
class C extends React.PureComponent<Props, {}> {
constructor(props: Props<T>) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
public render(): JSX.Element {
return <this.props.element>
{this.props.children}
</this.props.element>;
}
}
function foo(): JSX.Element {
return <C element={new tr/* What goes here?? */}/>;
}
返回;
我想你想要HTMLTableRowElement
@Joe获取HTMLTableRowElement构造函数的语法是什么?我得到错误消息JSX元素类型“HTMLTableRowElement”不是JSX元素的构造函数。
return <C element={<HTMLTableRowElement>(document.createElement('tr'))}/>;