Dynamically injecting object names

Hey folks,
Pretty new to panel, would appreciate your help.
Trying to integrate flex-layout into my panel using ReactiveHTML.
I want to be able to render bokeh models within the tabs of the layout.
I used the factory method of “flexlayout-react” to produce my react components. When rendering a child I creating a reference and in the return statement im appending a child which is supposed to be the div within my FlexLayout custom ReactiveHTML based component so I would be able to render the bokeh figure. Here is my code:

import json
from pathlib import Path
import panel as pn
import param
from panel.reactive import ReactiveHTML
from bokeh.plotting import figure
from bokeh.sampledata.penguins import data
from bokeh.models import Button, CustomJS

class FlexLayout(ReactiveHTML):
    layout_path = param.String(default="assets/layouts/new.json")
    layout = param.Parameter()
    sample_view = param.Parameter()

    def __init__(self, **params):
        p1 = figure()
        p1.scatter("flipper_length_mm", "body_mass_g", source=data)
        self.sample_view = p1

        with open (self.layout_path) as f:
            self.layout = json.load(f)
    __javascript__ = [

    _stylesheets = [

    _template = """
        <div id="root">
            <div id="obj0"> 

    _scripts = {
        "render": (Path(__file__).parent / "js" / "flex-layout.jsx").read_text("utf-8")

    _extension_name = "custom_flex_layout"

pn.extension("custom_flex_layout", sizing_mode="stretch_both")

flex_layout = FlexLayout()
sample_layout = pn.Row(flex_layout)

Here is the flexlayout-react implementation:

function readModel(url) {
    // Create a new XMLHttpRequest object
    const xhr = new XMLHttpRequest();
    // Open a synchronous request
    xhr.open('GET', url, false);
    // Send the request
    // Check the status of the request
    if (xhr.status === 200) {
        // Request successful
        const json = JSON.parse(xhr.responseText);
        return FlexLayout.Model.fromJson(json);
    } else {
        console.error('Error fetching the JSON file. Status:', xhr.status);

function Child(props) {
    const childRef = React.useRef();

    React.useEffect(() => {
    }, [ ]);

    return React.createElement("div", {
        id: props.node.getName(),
        className: 'flex-tab',
        ref: childRef

function App({ layout_path }) {
  const model = readModel(layout_path);
  const layoutRef = React.createRef();

  React.useEffect(() => {
  }, [])

  function onAddFromTabSetButton(node){
    layoutRef.current.addTabToTabSet(node.getId(), {type:"tab", component:"obj", name:"New"});

  function onRenderTabSet(node, renderValues){
    if (node.getType() === "tabset"){
                    src: "assets/add.svg",
                    alt: "Add",
                    key: "Add button",
                    title: "Add Tab",
                    style: { width: "1.1em", height: "1.1em" },
                    className: "flexlayout__tab_toolbar_button",
                    onClick: () => onAddFromTabSetButton(node)

  const factory = (node) => {
    var component = node.getComponent();
    if (component === "obj"){
        return React.createElement(
                node: node, 
                el: obj0
    } else if (component === "button") {
        return React.createElement(
                className: 'button-class',

  return React.createElement(FlexLayout.Layout, {
    ref: layoutRef,
    model: model,
    factory: factory,
    onRenderTabSet: onRenderTabSet

function renderApp(data){

        React.createElement(React.StrictMode, {
            children: React.createElement(App, {layout_path: data.layout_path})


My problem is that for now Im forwarding obj0 as the “el” property to the Child class, but my goal is to use obj + node.getId(), and also generate the divs within the templates dynamically:

# In the component set children as a List parameter and then initialize it with 
children = param.List(default=[])

# Then in the template
<div id="child">
                {% for obj in children%}
                    <div id="obj{{ loop.index0 }}">
                        ${children[{{ loop.index0 }}]}
                {% endfor %}

And my goal is when node is a component of type “obj” it will render the plot indexed within its id field, for example node with id=0 will render children[0] (that is wrapped with obj0 in my template).
This is an example for a model (its my “assets/layouts/new.json” file):

  "global": {},
  "borders": [],
  "layout": {
      "type": "row",
      "weight": 100,
      "children": [
              "type": "tabset",
              "weight": 50,
              "children": [
                      "id": 0,
                      "type": "tab",
                      "name": "One",
                      "component": "obj"

Would appreciate any leads, thank you in advance.