reactjsparcel

embeddable widget using React.js uncaught error minified react error #299


I am going to build an embeddable widget using React.js library. I built the widget using the command "parcel build src/index.js --no-source-maps -d widget" successfully. But when running the js and css files which are built in any website, I have encountered an error "Uncaught Error: Minified React error #299". I researched many blogs, but I haven't found the solution. Please let me know the solution if you have experience.

enter image description here


Solution

  • I had this same error with my React app - a similar embeddable widget app as well. The way I fixed it was when I added the widget to a webpage, I had to add a div with the "root" id - the error comes from not being able to create a root for the app so by explicitly adding a root div then the app rendered properly.

    Something like this:

    <div id="root"></div>
    <script src="path-to-script.js"></script>
    

    Hope this helps.