Can i use more than one reactjs version in one website? - reactjs

I am doing plugin using Reactjs. This plugin is easy to pluggable with any site. For plugin build, I am using "webpack" and follow commonjs/es6 module system. Suppose end user may be used react in their website, Is it affect my plugin? (ex: like two jquery we are using in website then we use jquery.noconflict())?
Note: I didn't export react outside. Is React maintain any information in global?

Short answer is no.
Most 3rd party React components require that the application consuming them provide a compatible version of React.
This is why you see React as a peerDependency in the package.json of these libraries.

Related

how can I use two different version of react cdn in a single page?

I want to use react library as cdn in wordpress. I have installed Divi theme but it loads older version of react in the window. I need the latest version of react to use my plugin in gutenberg. How can I acheive this as no conflict issue while two react script is loaded?

Using Nextjs components in a package consumed by a nextjs application

I have a Nextjs website that consumes a package with a set of react components. This package has nextjs installed too but its extremely heavy and only used for next links. I am working on removing nextjs from the package.
Is there a way I can use the next link component in the package without adding next as a dependency. It seems strange to add it in both. I would like to know the recommended approach.
Thanks
This shouldn't be an issue. Nextjs should only get installed once. All new installations with override any previous installation. To avoid conflicts, just make sure your project and package have the same versions of react.

Can I use React components from npm in an existing web page w/o create-react-app?

I know that in React you can add components to any existing page from this excellent documentation (https://reactjs.org/docs/add-react-to-a-website.html). However, in that example the component is built from scratch. I am building several of my own components from scratch too but I would like to use a few different components from npm as well. For example, there is one called react-ace (https://www.npmjs.com/package/react-ace).
If a component is published on npm (and available on unpkg.com) is it possible to add it to an existing page like in the React docs example above? I have tried adding a script tag with this as the source: https://unpkg.com/react-ace#9.4.1/dist/react-ace.js/main.js but that does not make the AceEditor available. Or, do components have to be processed somehow in order to use them?
Note: I am also exploring using create-react-app to build and share the app and I may end up doing that but I want to know if any npm React component can be used in an existing page and if so how?

React Native Boilerplate template

I'm a ReactJS developer, and I'm learning React Native for an upcoming project.
With ReactJS, there is a great boilerplate which is widely used by ReactJS developer: https://www.reactboilerplate.com/ (There are also many other great boilerplate).
However, after researching for a day, I haven't figured something similar to React Native. Please, can someone suggest to me a boilerplate for React Native?. Is there a standard project structure out there?
Actually there is not much difference from ReactJs. It really depends on navigation library you are choosing. The best options are:
React Navigation (JS based navigation library)
React Native Navigation (Native navigation library)
I suggest seeing example projects of both libraries.
You should try:
https://github.com/react-community/create-react-native-app
Also read documentation about React Navigation.
You can use the react native Ignite CLI Github which seems to be very similar, it's probably one of the most advanced Boilerplates for React Native and can be difficult to understand, thus when starting with React Native I would advise you to use none at all or just use your React structure
I recommend using the Handidev boilerplate since it only consists of the minimum library that every react-native project uses. And it has been used in many projects. This boilerplate consists of :
latest react-native version
react-navigation and its dependencies
redux-toolkit ( state management)
react-native vector icons ( for icons)
You can check it out here:
javascript version: https://www.npmjs.com/package/#handidev/react-native-boilerplate
npx react-native init MyApp --template #handidev/react-native-boilerplate
TypeScript version: https://www.npmjs.com/package/#handidev/react-native-typescript-boilerplate
npx react-native init MyAppName --template #handidev/react-native-typescript-boilerplate

How can I specify different versions of react in my react/react-native repo

Two questions.
I currently have a react web app, using higher order components, and redux to manage state. I am using react version 15.6.1.
I am now looking to create a react-native project. Since I am planning to integrate the react-native and the react codebase into the same repo, I am trying to figure out the best way to do this, specifically regarding the version of react.
The latest version of react-native (0.53rc0) has a peer dependency on react 16.2.0.
The react app breaks when I tried to upgrade to react v16 and I don't have time to do those fixes at this stage, so I am stuck with react 15.6.1 for a while longer. Does this mean I have to use an older version of react-native (looks like 0.42 supports react v15), or is there some other way in which I can use the latest version of react for react-native only, while keeping it in the same repo.
To clarify - the reason I want to keep it in the same repo, is because I already have higher order components, so in theory I just have to write the react-native components which will to my understanding then be called by the higher order component when running in the mobile app.
If anyone has or knows of examples of repos on github where this has been done (combined react and react-native project), that would be great so that I can get an idea of what such a project would look like once done.

Resources