Home > database >  React using vite throws an error when refreshing the website
React using vite throws an error when refreshing the website

Time:12-22

I am watching a yt series and having some problems. I made the project using vitejs.

When I run: npm run dev on this Project everything works. But when I make changes in the project and save them, the website sometimes doesent update and if it updates it shows me this error:

*Uncaught SyntaxError: The requested module '/src/App.jsx?t=1671702153370' does not provide an export named 'default' (at main.jsx?t=1671702153370:4:8)*

if I then restart the server (I go to the command line and press r) it works again.

does someone know how to get rid of this error and how to make it so the website updates without restarting the server?

If I restart the server the error disappears. I tried changing the home component and changing it to .js instead of .jsx but that changed nothing.

CodePudding user response:

I checked your repo, in your App.jsx try this,

import Navbar from './Navbar';
import Home from './Home';

export default function App() {
  return (
    <div className="App">
      <Navbar />
      <div className="content">
        <Home />
      </div>
    </div>
  ) 
}

The export default App; only works with, arrow functions.

  • Related