#Unexpected token '.' react-quiz-component library

11 messages · Page 1 of 1 (latest)

dull merlin
#

I have reproduced the issue here: https://codesandbox.io/p/sandbox/astro-mdx-forked-tphlyx?file=%2Fsrc%2Fpages%2Findex.mdx%3A1%2C1

Tried to work it out in ai-support here: https://discord.com/channels/830184174198718474/1168211097015292025

Made an issue in the library here and the awesome maintainer @mossy herald is supporting as well: https://github.com/wingkwong/react-quiz-component/issues/150

Is there any vite/astro config I can use to avoid this issue?

Thanks in advance for any suggestions I've been stuck for a while now. 🙂

GitHub

react-quiz-component library may not be fully compatible with Astro or Vite's module system out of the box. Astro uses Vite as its internal build engine, which supports ESM (ECMAScript Modules)...

merry star
dull merlin
#

here is the updated sandbox with the same error:

dull merlin
merry star
#

Ah you're using preact, try it with react integration

dull merlin
merry star
#

I see - I tried that library and it only works with client:only="react" if I use it in an .astro page, not .mdx. Just importing it in .mdx results in that .error (and any other client directive from .astro).

So as a workaround, you can wrap the <Quiz client:only="react" /> in an Astro component and use that in your mdx instead. Doesn't seem to build though unfortunately

dull merlin
mossy herald