Create new node onclick

function temp() {
    return (
       <Frame
        width={500}
        height={500}
       >
        <Text  onClick={()=>{
            const node = figma.createRectangle()
            // how can I append this node to the frame?
        }}>Click me to add new rectangle</Text>
       </Frame>
    )
}

I am trying to create a node using createNodeFromJSXAsync by using the above method