I want to dynamically add few div elements just when component is mounted. I tried with following code
<div className="resumebuilder__structure" ref="panel_holder">
</div>
My function which is called in lifecycle hook
getPanels = () => {
return this.props
.resumeTemplate
.roughTemplateStructure
.roughScale.map((roughS) => {
const uid = uuid();
this.updatePanelInTemplate(uid);
const elem = <div ref={uid} className={roughS.class} ></div>;
return elem;
});
}
lifecycle method
componentDidMount() {
this.refs.panel_holder.appendChild(this.getPanels());
}
But I am getting following error
Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
Does anyone has any idea?
---- Update--
Although I continued with other methods but the answer is still not found. Please do comment if you know anything.