How to get a node reference from a widget?

function update(node, count) {
    // set some property on node using count

function Widget() {
  const [count, setCount] = useSyncedState('count', 0)

  return (
    <Frame width={100} height={100} >
         () => {
            // update(??, count)
            setCount(count + 1)
       The count is: {count}

How do I send the text node’s id or WidgetNode’s reference to the update function?

I think we can get the WidgetNode’s reference from figma.currentPage.selection[0], right? Is there any way to get a TextNode’s reference if the widget has multiple TextNodes?

You can get a WidgetNode, but not its nested nodes.