markfinger / python-react

Server-side rendering of React components
MIT License
1.62k stars 116 forks source link

Unexpected token in component #104

Closed hizneway closed 2 years ago

hizneway commented 2 years ago

Do you know why this may be happening?

Stack trace: SyntaxError: {mypath}/index.jsx: Unexpected token (6:3)


  5 |       return (
> 6 |           <div>
    |           ^
  7 |               hello!
  8 |           </div>
  9 |       );```
markfinger commented 2 years ago

It usually means the renderer isn't running compiled JSX. The JSX format isn't executable in a JS engine natively, so you need to either run something like the babel loader (which compiles them on demand) or precompile with something like webpack/vite/etc.

hizneway commented 2 years ago

Thanks for the quick reply. That makes sense. I was able to get it working.