import { Templates, Components, Component } from 'formiojs';
Templates.addTemplate('mytemplate', {
<div ref="mychild">1</div>
<div ref="mychild">2</div>
<div ref="mychild">3</div>
class MyComponent extends Component {
// By calling super.render, it wraps in component wrappers.
return super.render(this.renderTemplate('mytemplate', {
data: 'these are available in the template'
this.refs.myref; // This will be either null or the div with "myref" set on it.
this.refs.mychild; // This will be either null or an array of divs with "mychild" set on them.
// Called on redraw or rebuild. The opposite of attach.
// Called on rebuild. The opposite of init.
Components.addComponent('mycomponent', MyComponent);