anywidget works in marimo notebooks and is the recommended way to build widgets. IPYReact throws JS errors. I assume this is because of the shared module. I'm not asking ipyreact to change, I just want to link it here for visibility. Here is the bug I filed for marimo
marimo-team/marimo#2904