React V17.0.2

0 views
Skip to first unread message

Theodora Andy

unread,
Aug 5, 2024, 3:51:14 AM8/5/24
to lgestordepo
everyoneI am trying to externalize React v17.0.2 in a project because it will work with single-spa. I have externalized react, react-dom and react-router-dom, and I have used the JSDelivr network to provide the libraries through an importmap script.

As you can see, the stack trace points to @azure/msal-react's MsalProvider component. Because externalizing is the only thing that changes between "works" and "doesn't work", I bet the problem is that I somehow have multiple react-dom's somewhere. That's what my instinct tells me.


At this point I just say: "Let's delete react and react-dom from node_modules, and if it is being used by Vite's build process, I'll know". Sure enough, I did this and an error appears: It tells me that react/jsx-runtime could not be resolved. I was happy because I thought this would be a matter of externalizing this bare identifier and then provide the shared copy through the importmap.


This is where I get stuck: React is not really available in ESM, and as far as I know, only the JSDelivr network has an ESM URL for it, which is the one I show in the importmap. Now what's the URL for react/jsx-runtime? Doing "react/": " @esm-bundle/[email protected]/+esm/" as per MDN doesn't work.


I do notice that the error's stack trace, up to MsalProvider, shows "react-dom.production.min.js", and after it shows "react.development.js". I don't know enough React to realize if this is a concern or not.


I might not be the only one who is really scared of change in technology causing a break in my code, but you don't have to fear anymore. with the new react 18 deployed, I will show you how to downgrade to react 17.0.2 with ease, so you can have enough time to prepare for the upgrade.


There is one caveat that the dependency of "@testing-library/react": "^13.0.1" is not downgraded. I think to fully support react17, this should be of version 12 not 13. Do you know how to fix this issue?


After publishing the package, the package works fine in React v17.0.2, but shows error when used in React v18.2.0. The error states mismatching version of React and renderer (such as React DOM) or you might have more than one copy of react in the same app.


i think all looks gud you have react & react-dom specified as peerDependencies, you just need to remove react-dom & react from your dependencies, right now you are telling npm to explicitly install your deps version and not letting peerDependency do its thing and rely on app's react & react-dom version


The react package contains only the functionality necessary to define React components. It is typically used together with a React renderer like react-dom for the web, or react-native for the native environments.


Note: by default, React will be in development mode. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages. Don't forget to use the production build when deploying your application.


We are running this in a react component - using Create-React-App, and when running this using the development mode (react-scripts start) - unminified - it is loading perfectly fine and working really well:


However - when create a minified build (react-scripts build) and serve it from there - it stops mid-loading after the VectorTileServer call - which seems to respond well with the same results as the unminified one. I've gone through and checked every call Arcgis makes and they all match up perfectly - the only difference is that it won't go on and load the next call. How could this be?


I'm experiencing something similar. Using React 17 in dev mode the AGO webmap loads as expected. Run build and the web map does not load at all, although I see the esri-view-root div added to the DOM. I noticed the canvas tag, shown below in dev mode, is missing from the DOM when running the production build version of the app:


Note, all version references to react and react-dom now refer to 17.0.1. Start the debug build of your project again with gulp serve --nobrowser, refresh your browser window, and your React components will start rendering as expected.


Server-side rendering (SSR) is a popular technique for rendering a client-side single page application (SPA) on the server and then sending a fully rendered page to the client. This allows for dynamic components to be served as static HTML markup.


This approach can be useful for search engine optimization (SEO) when indexing does not handle JavaScript properly. It may also be beneficial in situations where downloading a large JavaScript bundle is impaired by a slow network.


Note: An earlier version of this tutorial installed babel-core, babel-preset-env, and babel-preset-react-app. These packages have since been archived, and the mono repo versions were utilized instead.


Note: An earlier version of this tutorial used a .babelrc file (without the .json file extension). This was a configuration file for Babel 6, but this is no longer the case for Babel 7.


SSR can also often help with performance because a fully loaded app is sent down from the server on the first request. For non-trivial apps, your mileage may vary because SSR requires a setup that can get a bit complicated, and it creates a bigger load on the server. Whether to use server-side rendering for your React app depends on your specific needs and on which trade-offs make the most sense for your use case.


How do I deploy this to Netlify? I tried and got no errors but it seems to get stuck at the same point during the deployment every time and just stays there doing nothing except using up my build minutes.


Deciding which framework or library to use when building your next application can become quite a daunting task once you realize just how many options you have within JavaScript's ecosystem which comprises not only different tools for developing, testing, debugging, and deploying applications; but also encompasses libraries, software packages, and numerous resources that ensure a smooth development process when incorporated together. The ecosystem makes it possible for developers to build applications from code to deployment, which makes JavaScript a good choice for front-end development projects.


In this article, we'll take a look at two popular front-end frameworks, Angular and React, and explore their history, use-cases, performance aspects, and benefits to help you determine which you should use for your next project.


Angular is a typescript-based free and open-source development framework. Angular is used for designing robust and scalable web applications. It's bundled with libraries that help you extend your application with a variety of features. Some features are client-server communication, data-binding, form management, and routing. Angular is used for building single-page client applications using HTML and TypeScript. The framework is maintained by Google and a large community of developers actively contributing to the development of the framework.


Angular is a rewrite of AngularJS, which was introduced in 2010. The framework was revised because the landscape of frontend development was evolving and AngularJS was falling behind. New features and enhancements were emerging, but Angular was limited and could not support them. This caused drawbacks for the core team because it became difficult to support the emerging changes on the web, so they reached a roadblock in improving the framework. At that point, the best thing was to rewrite the entire framework from the ground up.


From version 2.0 to the current version of 12.1.4, changes and improvements were made to ensure that the framework deploys applications fast in mobile, desktop, and browser environments. And to provide a seamless experience for the framework, Angular used a typed superset of JavaScript called TypeScript for the rewrite.


React is a front-end JavaScript library developed by Facebook and a large community of web developers. It is a free open-source front-end JavaScript library that is used for building user interfaces, single-page applications, and mobile applications. React makes it easy to interact with components to build dynamic websites. The current version of React is v17.0.2, released in March 2021, with plans for React 18 already in the works.


React.js, developed by a Facebook developer named Jordan Walke, was released officially on May 29, 2013. Jordan Walke initially created faxJS, which was the prototype of React. The original problem was that Facebook Ads were hard to manage, the codebase became too large and unmaintainable due to the fact that a small change could cause the entire app to re-render. This was called cascading updates, and they had to come up with a solution to fix the problem. Hence, the creation of React.


React was created to simplify and speed up the development process of web and mobile applications. At its core, React uses JSX as a templating language. This promotes the construction of machine-readable code and delivers a phenomenal user experience.


When selecting a framework, there is a list of criteria you should consider. In this section, we'll share a detailed comparison of both frameworks in terms of their learning curve, performance, architecture, scalability, popularity, community, documentation, application types, and career potential.


The angular framework is divided into different core parts: modules, templates, services, and components. Angular components are the basic building blocks of the Angular framework, and they are organized into NgModules.


You write Angular applications by composing HTML templates with Angularized markup, writing component classes to manage those templates, adding application logic in services, and boxing components and services in modules. Then you launch the app by bootstrapping the root module. Angular takes over, presenting your application content in a browser and responding to user interactions according to the instructions you've provided.

3a8082e126
Reply all
Reply to author
Forward
0 new messages