Giter Site home page Giter Site logo

Comments (6)

sasoria avatar sasoria commented on May 25, 2024

Thanks for writing an issue on this, @norama 🙌 I'm running Astro in production with React micro-frontends and it works fine with useState. This error is caused by running Astro in dev mode and app-a in production mode. Astro has its own React version in dev mode which is the reason for the error you've mentioned.

If you want to run the apps locally you have to run Astro with npm run preview. Sorry for not being clear on this in the readme, I'll update it as soon as possible!

from astro-microfrontends.

sasoria avatar sasoria commented on May 25, 2024

Another approach would be to allow different versions of react running in the shell, though I have not tried it with useState. Here's an example on how to do it with injection points for the micro-frontends.

from astro-microfrontends.

norama avatar norama commented on May 25, 2024

Thanks a lot for the quick answer and update!
It is working with npm run preview just in this case there is no hot module reload and other nice dev mode stuff...
How do you use dev mode?
Or just use dev mode for the microfrontends in isolation and using prod mode always when running astro with the microfrontends together?

from astro-microfrontends.

norama avatar norama commented on May 25, 2024

Another approach would be to allow different versions of react running in the shell, though I have not tried it with useState. Here's an example on how to do it with injection points for the micro-frontends.

Thanks, this is working with npm run dev!!!

from astro-microfrontends.

sasoria avatar sasoria commented on May 25, 2024

Awesome. I usually develop each app in isolation in dev mode. In each micro-frontend you can add a page layout in index.css and import it in main.tsx. This won't get bundled to production because the entry point is Microfrontend.tsx

For the Astro app, you can mock the micro-frontend bundles in a local server and run it in dev mode.

from astro-microfrontends.

sasoria avatar sasoria commented on May 25, 2024

Closing this issue, I'm planning on adding more documentation in the future!

from astro-microfrontends.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.