Zulip Chat Archive

Stream: general

Topic: issue loading user widget


Frederick Pu (Oct 13 2025 at 12:51):

i'm getting the following error:

TypeError: Cannot read properties of undefined (reading 'children')

even though none of my logic involves children in any way at all:

import React, { useEffect, useRef, useState } from 'react';
import * as d3 from 'd3';

function GameStateTree(props) {
  // const treeData = tree ?? { name: "root", children: [] }; // The root node of the game state tree
  const svgRef = useRef(null);


  return (
    React.createElement('div', {
        style: {
            width: '100%',
            height: '100vh',
            display: 'flex',
            flexDirection: 'column',
            background: '#f9fafb'
        }
        },
        React.createElement('div', {
            style: {
            flex: '1',
            overflow: 'auto'
            }
        },
            React.createElement('svg', { ref: svgRef })
        )
        )
  )
};

export default GameStateTree;

𝚠𝚘𝚓𝚌𝚒𝚎𝚌𝚑 𝚗𝚊𝚠𝚛𝚘𝚌𝚔𝚒 (Oct 14 2025 at 04:32):

It's hard to say what's going on without the accompanying Lean code. Fwiw,

import Lean

@[widget_module]
def myWidget : Lean.Widget.Module where
  javascript := "<JS CODE HERE>"

#widget myWidget

works for me.

Frederick Pu (Oct 14 2025 at 13:48):

i ended up fixing it by running tsc before rollup when building the js source files


Last updated: Dec 20 2025 at 21:32 UTC