this.cliponSwatchesContainer.current.append(
React.createElement(
'button',
{
id: colorSwatches[cliponSwatch],
className: this.state.swatchClassName,
onClick: (e) => this.setFrame(e, colorSwatches),
ref: this.swatch,
},
React.createElement(
'img',
{ src: this.state.swatchImgSrc, alt: this.state.swatchImgAlt },
null
)
)
);
我正在尝试将document.createElement
转换为React.createElement
。当我使用appendChild()
时,出现以下错误:
未捕获的TypeError:无法在“节点”上执行“ appendChild”:参数1的类型不是“节点”。
因此,我尝试使用append()
,错误消失了,但是现在UI显示:
[对象对象] [对象对象]