class {
    onCreate() {
        this.state = { items: [] };
    }

    addItem(id) {
        this.state.items = this.state.items.concat(id);
    }

    removeItem(id) {
        this.state.items = this.state.items.filter(item => item !== id);
    }
}

<div>
    <div for(item in state.items) key=`loop1:${item}`>
        <span/>
    </div>
    <for(var i = 0; i < state.items.length; i++)>
        <div key=`loop2:${state.items[i]}`>
          <span/>
        </div>
    </for>
</div>