The error message received indicates that you should be importing the createRoot method from react-dom/client instead of from react-dom.
To fix the issue, modify your import statement for createRoot to look like this :
import { createRoot } from 'react-dom/client';
So the modified code should be :
import React from 'react';
import { createRoot } from 'react-dom/client';
import Switch from './components/Switch';
const root = createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<Switch />
</React.StrictMode>
);