If you enable the "bundle widgets when running locally", then you could see your widget as it is in production.
In our case, we use the non-minimized library and add some more changes:
In React, in define module:
define("MxReactWidget/widget/lib/react/react", [], f)
ReactDOM, in define module:
// RequireJS } else if (typeof define === "function" && define.amd) { define(['MxReactWidget/widget/lib/react/react'], f);
Basically, you define explicitly "widget/.../lib/react" .
There is other way you could write widget in React only but it's not officialy published. This way you don't need to bundle React in your package (i think). You could take a look at: https://github.com/mendixlabs/progress-circle. With some additional setting, you even can use tsx to make the coding easier.
At the moment react widgets are R & D at Mendix. You will have to wait until its official released for the community.
see https://forum.mendix.com/link/questions/87037
so please build the widgets using dojo see
This is our demo project:
https://reactwidgetapp100.mxapps.io/index.html?profile=Responsive
you may look at line 18997 and 58 in widgets.js
We fixed the issue for now by removing all references to React and ReactDOM from the widget itself, so remove the reference in the define method and also removed the react.js and react-dom.js files from the widget lib folder.
After that we added the widget files in the index.html above the mxui.js and with that the errors are resolved and the widget works fine again.