I found the answer in a post by jeremy.a.gray
I had to change the external scripts in codepen to use react17 instead of 18.
This is can be done by changing
https://unpkg.com/react/umd/react.production.min.js
https://unpkg.com/react-dom/umd/react-dom.production.min.js
to
https://unpkg.com/react@17/umd/react.production.min.js
https://unpkg.com/react-dom@17/umd/react-dom.production.min.js
And then changed the code from
const root = ReactDOM.render(document.getElementById("root")); root.render(<Calculator />);
to
ReactDOM.render(<Calculator />, document.getElementById("root"))