Can I manually update the React version in my React Native app? - reactjs

I created a 0.69.1 React Native app that came with React 18.0.0. Are these versions pinned to each other, or is it okay to update React to 18.2.0?

React Native 0.69.1 has a peer dependency on React with version "18.0.0" (exactly that version) (from package.json). So the short answer is no, you cannot change
the version of React to 18.2.0 while keeping React Native at 0.69.1.
It looks like RN 0.70.x is going to have a peer dependency on React with version "18.1.0" (again from package.json), so you can update both when RN 0.70.0 is released.

Related

How to update React and dependencies to a specific version?

I have project with massive amount of dependencies. It uses react 16.8. I need to update React to a specific version: React: 17.0.2
How to do it automatically? I don't want to check each package if it is compatible with this version of React.
It seems all existing automatic methods update to the latest version only(npm-check-updates).
To change the React version your project is using you need to run the following command
npm install –save react#<version>
, where <version> is a variable. You should substitute it for the desired version of React.

How to update React in a project created using Create React App?

I have a project created with Create React App. The documentation regarding how to update the React version seems to be pretty poor.
There is some documentation here https://facebook.github.io/create-react-app/docs/updating-to-new-releases . This seems ambiguous though - are these instructions just to update CRA itself and react-scripts? I have followed the instructions - my react-scripts is up to date at v2.1.1, but my React version is only 16.5.2 - I need 16.6 for a certain feature.
Updating react-scripts will not update your React version, you need to do that yourself by updating both react and react-dom (must be the same). Check this and this. I was confused about this too!

react: what happend if I import a component which import a higher version react in a lower version react project

react: what happend if I import a component which import a higher version react in a lower version react project.
Does there will has two diff version of react in diff module? or just has one react?
Does there any diff between webpack and native es6?
Only one version of react if defined as peer dependency. Of course you should only use features supported by both versions.

Does react-native support react 16?

When trying react-native init myproject I am getting 16.0.0-alpha.5 as a react dependency
When installing react#16 I am getting the following warning:
UNMET PEER DEPENDENCY react#16.0.0
Note: Using react-native v0.49.1.
When you do react-native init, it initialize the project with the last react version working with it. React has always a few steps of development ahead of React native, because React Native is built with React. So you will have the latest react version included in the react native init project in a few weeks.

Creating a React and React Native component in a single npm package

Is it possible to create a component, living in a single npm package, that would work in both React and React Native?
I have created two variations of a component (View vs div and so on), one for the web and one for react native. I could easily use a build script or something like preprocessor.js to build a react or react-native output of the library but is there a better way?
Have anyone had any luck building a component that you could simply npm install into a react or react native project and just have it use the correct implementation? Or would I have a problem where both the react and react-native dependencies would exist in my package.json? Thanks!

Resources