How to use local node modules in eas build? - react-native

I have a scenario where I have to use patch-package due to react-native library issue. It worked perfect in development env. But while eas build in cloud it downloads fresh packages of node modules so the error remain same after building the apk.
I tried npx expo run:android --variant release . It created the app locally and working perfect. But if I use eas build -p android --profile preview . after apk build , the app crashed.
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
invariant(
false,
'ColorPropType has been removed from React Native. Migrate to ' +
"ColorPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get EdgeInsetsPropType(): $FlowFixMe {
invariant(
false,
'EdgeInsetsPropType has been removed from React Native. Migrate to ' +
"EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get PointPropType(): $FlowFixMe {
invariant(
false,
'PointPropType has been removed from React Native. Migrate to ' +
"PointPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get ViewPropTypes(): $FlowFixMe {
invariant(
false,
'ViewPropTypes has been removed from React Native. Migrate to ' +
"ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
);
},
for this reason I have used patch-package.

Related

react native linking custom fonts after removing react-native link

before react-native 0.70
I used the following configuration
//file react-native.config.js
module.exports = {
project: {
ios: {},
android: {},
},
assets: ['./src/assets/fonts/aaa', './src/assets/fonts/bbb'],
};
and just calling
react-native link
it handles the linking job now
I'm getting error: unknown command 'link'
how to do the same job?
this was removed react-native link after 0.69 i believe
you can use the following it works
npx react-native-asset

React native 0.69.1 I am facing issue 'deprecated-react-native-prop-types'

Error:
deprecated-react-native-prop-types
"react-native": "0.69.1",---- this error comes only in the latest version of react-native
I am facing this issues when I installed any of this library
-react-native-snap-carousel
-react-native-fast-image
Requiring module
"node_modules/react-native-snap-carousel/src/index.js", which threw an
exception: Invariant Violation: ViewPropTypes has been removed from
React Native. Migrate to ViewPropTypes exported from
'deprecated-react-native-prop-types'.
open files
./node_modules/react-native-snap-carousel/src/carousel/Carousel.js
./node_modules/react-native-snap-carousel/src/Pagination/Pagination.js
./node_modules/react-native-snap-carousel/src/Pagination/PaginationDot.js
./node_modules/react-native-snap-carousel/src/ParallaxImage/ParallaxImage.js
edit
import { ... ,ViewPropTypes } from 'react-native';
to
import { ... } from 'react-native';
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
it will work...
This is a mistake of the old npm packages, and if the project is alive, then the developers fix it in new versions. And maybe this error will go away when you update the package to a newer one.
I found the solution for this error install typescript package should
also install type definitions which resolve the error
'deprecated-react-native-prop-types' for snap crousel library
$ npm install --save #types/react-native-snap-carousel
**THIS IS WORKING PERFECT FOR ME**
I PREFER TO FOLLOW THE FIRST APPROACH
OR you can follow different approach
find ViewPropTypes import in the node modules in which library this gives error
delete import this file from 'react-native' and create new import
import {ViewPropTypes} from 'react-native';
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
and its also work good but when you install new package or npm install again you have to do this steps againn for the libraries which gives same error
here is the answer
install this package deprecated-react-native-prop-types and if u install a new package search for this replace the below modules. these are the changes for node_modules/react-native/index.js
diff --git a/node_modules/react-native/index.js b/node_modules/react-native/index.js
index d59ba34..1bc8c9d 100644
--- a/node_modules/react-native/index.js
+++ b/node_modules/react-native/index.js
## -435,32 +435,16 ## module.exports = {
},
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
- invariant(
- false,
- 'ColorPropType has been removed from React Native. Migrate to ' +
- "ColorPropType exported from 'deprecated-react-native-prop-types'.",
- );
+ return require('deprecated-react-native-prop-types').ColorPropType;
},
get EdgeInsetsPropType(): $FlowFixMe {
- invariant(
- false,
- 'EdgeInsetsPropType has been removed from React Native. Migrate to ' +
- "EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.",
- );
+ return require('deprecated-react-native-prop-types').EdgeInsetsPropType;
},
get PointPropType(): $FlowFixMe {
- invariant(
- false,
- 'PointPropType has been removed from React Native. Migrate to ' +
- "PointPropType exported from 'deprecated-react-native-prop-types'.",
- );
+ return require('deprecated-react-native-prop-types').PointPropType;
},
get ViewPropTypes(): $FlowFixMe {
- invariant(
- false,
- 'ViewPropTypes has been removed from React Native. Migrate to ' +
- "ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
- );
+ return require('deprecated-react-native-prop-types').ViewPropTypes;
},
};

ViewPropTypes will be removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types

I am getting this warning in log :
ViewPropTypes will be removed from React Native. Migrate to
ViewPropTypes exported from 'deprecated-react-native-prop-types
even I haven't used ViewPropTypes anywhere in my code.
some of my packages are :
"#react-navigation/native": "^6.0.8",
"#react-navigation/native-stack": "^6.5.2",
"native-base": "^2.13.14",
"react": "17.0.2",
"react-native": "0.68.0",
"react-native-modal": "^13.0.0",
"react-native-responsive-screen": "^1.4.2",
"react-native-safe-area-context": "^4.2.4",
"react-native-screens": "^3.13.1",
"react-native-svg": "^12.3.0",
"react-redux": "^7.2.6",
"redux-thunk": "^2.4.1"
Solution:
Install patch-package into your project, as per the instructions.
Install deprecated-react-native-prop-types by running npm install deprecated-react-native-prop-types or yarn add deprecated-react-native-prop-types.
The invariant seems to be enforced in node_modules/react-native/index.js, starting at line 436:
here is my patch file react-native+0.69.3.patch
diff --git a/node_modules/react-native/ReactCommon/React-bridging.podspec b/node_modules/react-native/ReactCommon/React-bridging.podspec
index 5255c13..52a8eb0 100644
--- a/node_modules/react-native/ReactCommon/React-bridging.podspec
+++ b/node_modules/react-native/ReactCommon/React-bridging.podspec
## -30,7 +30,7 ## Pod::Spec.new do |s|
s.source = source
s.source_files = "react/bridging/**/*.{cpp,h}"
s.exclude_files = "react/bridging/tests"
- s.header_dir = "react/bridging"
+ s.header_dir = "."
s.header_mappings_dir = "."
s.compiler_flags = folly_compiler_flags
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/RCT-Folly\"",
diff --git a/node_modules/react-native/index.js b/node_modules/react-native/index.js
index d59ba34..349b4dd 100644
--- a/node_modules/react-native/index.js
+++ b/node_modules/react-native/index.js
## -435,32 +435,16 ## module.exports = {
},
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
- invariant(
- false,
- 'ColorPropType has been removed from React Native. Migrate to ' +
- "ColorPropType exported from 'deprecated-react-native-prop-types'.",
- );
+ return require('deprecated-react-native-prop-types').ColorPropType
},
get EdgeInsetsPropType(): $FlowFixMe {
- invariant(
- false,
- 'EdgeInsetsPropType has been removed from React Native. Migrate to ' +
- "EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.",
- );
+ return require('deprecated-react-native-prop-types').EdgeInsetsPropType
},
get PointPropType(): $FlowFixMe {
- invariant(
- false,
- 'PointPropType has been removed from React Native. Migrate to ' +
- "PointPropType exported from 'deprecated-react-native-prop-types'.",
- );
+ return require('deprecated-react-native-prop-types').PointPropType
},
get ViewPropTypes(): $FlowFixMe {
- invariant(
- false,
- 'ViewPropTypes has been removed from React Native. Migrate to ' +
- "ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
- );
+ return require('deprecated-react-native-prop-types').ViewPropTypes
},
};
So, change these lines to return the corresponding Prop Types from deprecated-react-native-prop-types instead:
Save and run npx patch-package react-native to save the patch.
Rebuild and the app should launch.
Only thing to keep in mind is that this patch will need to be reapplied with every upgrade to react-native, or until the libraries in question are updated to import from deprecated-react-native-prop-types instead.
This is the patch issue and can be resolved by just replacing few lines of code:
check if you have installed deprecated-react-native-prop-types package if not run the below command first.
yarn add deprecated-react-native-prop-types
inside node_modules/react-native/index.js
replace these functions with the below lines
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
return require('deprecated-react-native-prop-types').ColorPropType;
},
get EdgeInsetsPropType(): $FlowFixMe {
return require('deprecated-react-native-prop-types').EdgeInsetsPropType;
},
get PointPropType(): $FlowFixMe {
return require('deprecated-react-native-prop-types').PointPropType;
},
get ViewPropTypes(): $FlowFixMe {
return require('deprecated-react-native-prop-types').ViewPropTypes;
},
Temporary solution.
ignoreWarnings.js
import { LogBox } from "react-native";
if (__DEV__) {
const ignoreWarns = [
"EventEmitter.removeListener",
"[fuego-swr-keys-from-collection-path]",
"Setting a timer for a long period of time",
"ViewPropTypes will be removed from React Native",
"AsyncStorage has been extracted from react-native",
"exported from 'deprecated-react-native-prop-types'.",
"Non-serializable values were found in the navigation state.",
"VirtualizedLists should never be nested inside plain ScrollViews",
];
const warn = console.warn;
console.warn = (...arg) => {
for (const warning of ignoreWarns) {
if (arg[0].startsWith(warning)) {
return;
}
}
warn(...arg);
};
LogBox.ignoreLogs(ignoreWarns);
}
App.js
// import at the very top of everything.
import "../ignoreWarnings";
Here you go , i gave some extra in case you are using Expo 45 new gesture-handler 2.2 and NativeBase , the below removes the errors from ViewPropTypes and react-native-gesture-handler both from LogBox and console:
import { LogBox } from 'react-native'
import ignoreWarnings from 'ignore-warnings';
ignoreWarnings('warn',['ViewPropTypes','[react-native-gesture-handler]'])
LogBox.ignoreLogs([
'ViewPropTypes will be removed from React Native. Migrate to ViewPropTypes exported from \'deprecated-react-native-prop-types\'.',
'NativeBase: The contrast ratio of',
"[react-native-gesture-handler] Seems like you\'re using an old API with gesture components, check out new Gestures system!",
])
Recently I faced this issue in my two react native projects. These steps works for me 100%. I didn't get any deprecated props error, After i fixed the issue.
testing module resolver usage to fix deprecated issue in react-native based on discussion in related react-native issue link
Step 1
Install the plugin
npm install --save-dev babel-plugin-module-resolver deprecated-react-native-prop-types
or
yarn add --dev babel-plugin-module-resolver deprecated-react-native-prop-types
Step 2
create index.js file inside project folder resolver/react-native/ with following code
import * as StandardModule from 'react-native';
const deprecatedProps = {
ImagePropTypes: require('deprecated-react-native-prop-types/DeprecatedImagePropType'),
TextPropTypes: require('deprecated-react-native-prop-types/DeprecatedTextPropTypes'),
ViewPropTypes: require('deprecated-react-native-prop-types/DeprecatedViewPropTypes'),
ColorPropType: require('deprecated-react-native-prop-types/DeprecatedColorPropType'),
EdgeInsetsPropType: require('deprecated-react-native-prop-types/DeprecatedEdgeInsetsPropType'),
PointPropType: require('deprecated-react-native-prop-types/DeprecatedPointPropType'),
};
// Had to use a proxy because ...StandardModule made think react-native that all modules were
// being used and was triggering some unnecessary validations / native dep checks.
// This prevents that from happening.
const objProx = new Proxy(StandardModule, {
get(obj, prop) {
if (prop in deprecatedProps) {
return deprecatedProps[prop];
}
if (prop === 'Image') {
return new Proxy(obj[prop], {
get(obj, prop) {
if (prop === 'propTypes') return deprecatedProps.ImagePropTypes;
return Reflect.get(...arguments);
},
});;
}
if (prop === 'Text') {
return new Proxy(obj[prop], {
get(obj, prop) {
if (prop === 'propTypes') return deprecatedProps.TextPropTypes;
return Reflect.get(...arguments);
},
});
}
return Reflect.get(...arguments);
},
});
module.exports = objProx;
Step 3
configure module resolver inside babel.config.js, depends on your project requirement to blacklist/whitelist certain npm packages to prevent conflicting file.
example module-resolver config :
var path = require('path');
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
["module-resolver", {
"root": ["."],
resolvePath(sourcePath, currentFile, opts) {
if (
sourcePath === 'react-native' &&
!(
(
currentFile.includes('node_modules/react-native/') || // macos/linux paths
currentFile.includes('node_modules\\react-native\\')
) // windows path
) &&
!(
currentFile.includes('resolver/react-native/') ||
currentFile.includes('resolver\\react-native\\')
)
) {
return path.resolve(__dirname, 'resolver/react-native');
}
/**
* The `opts` argument is the options object that is passed through the Babel config.
* opts = {
* extensions: [".js"],
* resolvePath: ...,
* }
*/
return undefined;
}
}],
],
};
Step 4
You're using expo, should run this command
expo r -c
You're using React Native, should run this command
npm start -- --reset-cache
you using react-native 0.71.0
node_modules/react-native/index.js
STEP1
Corresponding Line Annotation Process
get ViewPropTypes(): $FlowFixMe {
// console.error(
// 'ViewPropTypes will be removed from React Native, along with all ' +
// 'other PropTypes. We recommend that you migrate away from PropTypes ' +
// 'and switch to a type system like TypeScript. If you need to ' +
// 'continue using ViewPropTypes, migrate to the ' +
// "'deprecated-react-native-prop-types' package.",
// );
return require('deprecated-react-native-prop-types').ViewPropTypes;
},
STEP2
Run patch-package for react-native
npx patch-package react-native
You must run the following to prevent console errors at runtime
**1) First run the following command in our project directory
$ npm install deprecated-react-native-prop-types
Then open the node modules, open the folder that u have installed before the
error occuired
in that folder index.js and remove the viewproptype in the file
then import the following
$ import { ViewPropTypes } from 'deprecated-react-native-prop-types';**
Got the solution !!!
first of all install the package :
npm install deprecated-react-native-prop-types
So when you check the call stack of the warning:
You can find where the ViewPropTypes error is from.
In my case its in the MultiSelect.
So you go in the file (you can click on it)
otherwise it's in node_module/react-native-multi-select/lib/react-native-multi-select.js
And you remove ViewPropTypes from the import of react-native
and you add it from deprecated-react-native-prop-types
So the code was :
import React, { Component } from 'react';
import {
Text,
View,
TextInput,
TouchableWithoutFeedback,
TouchableOpacity,
FlatList,
UIManager,
ViewPropTypes
} from 'react-native';
and it has to be :
import React, { Component } from 'react';
import {
Text,
View,
TextInput,
TouchableWithoutFeedback,
TouchableOpacity,
FlatList,
UIManager
} from 'react-native';
import { ViewPropTypes } from 'deprecated-react-native-prop-types'
Save and restart all the app.
/!\ Watch out if the warn is still there, it can be from another file, check the call stack again, do the same process. I had to do it also for the react-native-camera (RNCamera.js)
Hi, devs
So, edit node_modules is not good way to resolve the problem
I am using React Native with Expo CLI (RN 0.70.5, EXPO 47.0.6)
Follow step by step and be happy!
LETS GO!!
STEP 1:
run command yarn add --dev babel-plugin-module-resolver deprecated-react-native-prop-types
STEP 2:
in your root project create folder resolver, inside this create another folder react-native, inside this create index.js file.
looks like: ./resolver/react-native/index.js
open the file and paste this:
import * as StandardModule from "react-native";
const deprecatedProps = {
ImagePropTypes: require("deprecated-react-native-prop-types/DeprecatedImagePropType"),
TextPropTypes: require("deprecated-react-native-prop-types/DeprecatedTextPropTypes"),
ViewPropTypes: require("deprecated-react-native-prop-types/DeprecatedViewPropTypes"),
ColorPropType: require("deprecated-react-native-prop-types/DeprecatedColorPropType"),
EdgeInsetsPropType: require("deprecated-react-native-prop-types/DeprecatedEdgeInsetsPropType"),
PointPropType: require("deprecated-react-native-prop-types/DeprecatedPointPropType"),
};
const imgProx = new Proxy(StandardModule.Image, {
get(_, prop) {
if (prop === "propTypes") return deprecatedProps.ImagePropTypes;
return Reflect.get(...arguments);
},
});
const txtProx = new Proxy(StandardModule.Text, {
get(_, prop) {
if (prop === "propTypes") return deprecatedProps.TextPropTypes;
return Reflect.get(...arguments);
},
});
const objProx = new Proxy(StandardModule, {
get(_, prop) {
if (prop in deprecatedProps) {
return deprecatedProps[prop];
}
if (prop === "Image") {
return imgProx;
}
if (prop === "Text") {
return txtProx;
}
return Reflect.get(...arguments);
},
});
module.exports = objProx;
STEP 3:
Edit babel.config.js file:
add in presets array: "module:metro-react-native-babel-preset".
add in plugins array:
"module-resolver",
{
root: ["."],
resolvePath(sourcePath, currentFile) {
if (
sourcePath === "react-native" &&
!(
(
currentFile.includes("node_modules/react-native/") || // macos/linux paths
currentFile.includes("node_modules\\react-native\\")
) // windows path
) &&
!(
currentFile.includes("resolver/react-native/") ||
currentFile.includes("resolver\\react-native\\")
)
) {
return path.resolve(__dirname, "resolver/react-native");
}
return undefined;
},
},
]
STEP 4:
run expo r -c
CONGRATULATIONS, YOU ARE WELCOME 😉🇧🇷
You can wait for them to update the dependencies or update the imports manually or even better make a pull request to help the community.
Your issue might be in one of your packages, consider upgrading them to the latest version. I faced this issue after downgrading native-base to v2.15.2 from v3++. Moving back to version 3 did it for me
The problem is the react-native-camera plugin. If you don`t want to migrate to the latest plugin suggested. Must do the next steps:
The course of my solution, I went to the node-modules folder -> the react-native-camera folder and found the main file RNCamera.js
find ViewPropTypes import
import {
findNodeHandle,
Platform,
NativeModules,
requireNativeComponent,
View,
ViewPropTypes,
ActivityIndicator,
Text,
StyleSheet,
PermissionsAndroid,
} from 'react-native';
//delete import this file from 'react-native' and create new import
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
and its work good.
Of course install the new plugin:
npm i deprecated-react-native-prop-types
And edit the index.js of the folder node_module/react-native.
Replace these functions with the below lines
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
console.warn('');
return require('deprecated-react-native-prop-types').ColorPropType;
},
get EdgeInsetsPropType(): $FlowFixMe {
console.warn('');
return require('deprecated-react-native-prop-types').EdgeInsetsPropType;
},
get PointPropType(): $FlowFixMe {
console.warn('');
return require('deprecated-react-native-prop-types').PointPropType;
},
get ViewPropTypes(): $FlowFixMe {
console.warn('');
return require('deprecated-react-native-prop-types').ViewPropTypes;
},
1- install "deprecated-react-native-prop-types" with npm
"npm install deprecated-react-native-prop-types"
2-Then open react-native folder inside node_modules , There you will have index.js
3-Below comment note "// Deprecated Prop Types" you will see functions like this :
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
invariant(
false,
"ColorPropType has been removed from React Native. Migrate to " +
"ColorPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get EdgeInsetsPropType(): $FlowFixMe {
invariant(
false,
"EdgeInsetsPropType has been removed from React Native. Migrate to " +
"EdgeInsetsPropType exported from 'deprecated-react-native-prop-
types'.",
);
},
get PointPropType(): $FlowFixMe {
invariant(
false,
"PointPropType has been removed from React Native. Migrate to " +
"PointPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get ViewPropTypes(): $FlowFixMe {
invariant(
false,
"ViewPropTypes has been removed from React Native. Migrate to " +
"ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
);
},
Replace it with code below :
get ColorPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ColorPropType
},
get EdgeInsetsPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").EdgeInsetsPropType
},
get PointPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").PointPropType
},
get ViewPropTypes(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ViewPropTypes
},
Then save file and rebuild your project and run
I was having the same error and was lucky to resolve it within a short time.
In my case, I followed the following steps:
Install the patch-package by going to this website.
https://www.npmjs.com/package/patch-package
Install deprecated-react-native-prop-types –
npm install deprecated-react-native-prop-types
OR
yarn add deprecated-react-native-prop-types
Go to node_modules/react-native/index.js and change this starting from:
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
invariant(
false,
"ColorPropType has been removed from React Native. Migrate to " +
"ColorPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get EdgeInsetsPropType(): $FlowFixMe {
invariant(
false,
"EdgeInsetsPropType has been removed from React Native. Migrate to " +
"EdgeInsetsPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get PointPropType(): $FlowFixMe {
invariant(
false,
"PointPropType has been removed from React Native. Migrate to " +
"PointPropType exported from 'deprecated-react-native-prop-types'.",
);
},
get ViewPropTypes(): $FlowFixMe {
invariant(
false,
"ViewPropTypes has been removed from React Native. Migrate to " +
"ViewPropTypes exported from 'deprecated-react-native-prop-types'.",
);
},
With this:
// Deprecated Prop Types
get ColorPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ColorPropType
},
get EdgeInsetsPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").EdgeInsetsPropType
},
get PointPropType(): $FlowFixMe {
return require("deprecated-react-native-prop-types").PointPropType
},
get ViewPropTypes(): $FlowFixMe {
return require("deprecated-react-native-prop-types").ViewPropTypes
},
Save patch by running this command
npx patch-package react-native
Rebuild App
Note: If you upgrade react-native, you will need to reapply this patch.
You can copy this code to the highest level code before App.
const ignoreWarns = [
"Setting a timer for a long period of time",
"VirtualizedLists should never be nested inside plain ScrollViews with the same orientation",
"ViewPropTypes will be removed",
"AsyncStorage has been extracted from react-native",
"EventEmitter.removeListener",
];
const warn = console.warn;
console.warn = (...arg) => {
for (let i = 0; i < ignoreWarns.length; i++) {
if (arg[0].startsWith(ignoreWarns[i])) return;
}
warn(...arg);
};
LogBox.ignoreLogs(ignoreWarns);
I found this error when I install npm react-native-switch-pro ,but after much research I decide to uninstall it and I found it is the problem ,please if you install it try to uninstall it maybe it's the problem
just open the RNCamera file from the node modules and comment the import and where viewproptype is used... and you are good to go
I resolved it by running:
npm install deprecated-react-native-prop-types
By importing import {ViewPropTypes} from 'deprecated-react-native-prop-types',
wherever it is required in the node dependencies.
Today I was working on this problem and I fixed it like this:
Went to node_modules
Then to react-native-camera library
Then to the src folder inside react-native-camera
Then to RNCamera.js file
There I deleted ViewPropTypes imported from 'react-native' and in a new line wrote:
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
Hope it works for you too!
I found the root cause to remove deprecated type, hope this help someone:
Open yarn.lock (or package-lock.json), find "deprecated-react-native-prop-types"
Check which dependency using "deprecated-react-native-prop-types"
Update it to latest version
Even though you are not using ViewPropTypes in your codebase directly some of the packages may be using it.
You can update all the packages that are using ViewPropTypes to a newer version.
Do a search for ViewPropTypes in your node_modules folder.
Update all packages using ViewPropTypes to newer versions.
npx pod-install(for iOS)
Restart the bundler
Refresh your app
in my case, the error came from react-native-snap-carousel library so here is how I fixed it in just 6 steps:
Step 1: npm install deprecated-react-native-prop-types or yarn add deprecated-react-native-prop-types.
Step 2: open all of these 4 files which is exists in the directories
node_modules\react-native-snap-carousel\src\carousel\Carousel.js
and
node_modules\react-native-snap-carousel\src\pagination\Pagination.js
and
node_modules\react-native-snap-carousel\src\pagination\PaginationDot.js
and
node_modules\react-native-snap-carousel\src\parallaximage\ParallaxImage.js
Step 3: delete all ViewPropTypes which is imported from react-native and import it from deprecated-react-native-prop-types which is the module we installed at the Step 1, and put it in a separated line like this
import { ViewPropTypes } from 'deprecated-react-native-prop-types'
Step 4: add this line "postinstall": "patch-package", in package.json in scripts section. example:
"scripts": {
"start": "expo start",
"postinstall": "patch-package"
},
Step 5: run this command npx patch-package react-native-snap-carousel.
Step 6: run this command npm run postinstall
I solved it opening a node_modules with vscode and serching for all "ViewPropTypes" that is inside 'react-native' module and replace it for:
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
Before:
import { Platform, ViewPropTypes } from 'react-native'
After:
import { Platform } from 'react-native'
import {ViewPropTypes} from 'deprecated-react-native-prop-types';

React Native ios build folder outside of project root

When I run react-native run-ios --verbose I see that my app is created at
/Users/username/Library/Developer/Xcode/DerivedData/AppName-ztrewhgfdsjtizchezgdoiujklztre/Build/Products/Debug-iphonesimulator/AppName.app
instead of ios/build inside my project root.
I have been searching for ways to configure this inside react-native.config.js but could not find how to explictly stated in the docs.
This is my react-native.config.js:
module.exports = {
project: {
ios: {},
android: {},
},
assets: ["./assets/fonts/"],
}

How to disable autolinking on iOS?

I've installed react-native-localization in my react native project (v0.6). Library is not supporting autolinker yet so I need to disable it for iOS and Android in react-native.config.js.
I already tried to add dependencies in react-native.config.js. After that, I did react-native link react-native-localization command and build an app.
This is my react-native.config.js file:
'use strict';
const ios = require('#react-native-community/cli-platform-ios');
const android = require('#react-native-community/cli-platform-android');
module.exports = {
dependencies: {
'react-native-localization': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
ios: null,
},
},
},
commands: [...ios.commands, ...android.commands],
platforms: {
ios: {
linkConfig: ios.linkConfig,
projectConfig: ios.projectConfig,
dependencyConfig: ios.dependencyConfig,
},
android: {
linkConfig: android.linkConfig,
projectConfig: android.projectConfig,
dependencyConfig: android.dependencyConfig,
},
},
/**
* Used when running RNTester (with React Native from source)
*/
reactNativePath: '.',
project: {
ios: {
project: './RNTester/RNTester.xcodeproj',
},
android: {
sourceDir: './RNTester',
},
},
};
Error in simulator says:
"Please check your configuration. Did you run 'react-native link'?
As now, react-native has added the support for CocoaPods inside of his projects. (https://github.com/facebook/react-native/releases)
Sadly, i don't know why, but the autolinking feature never works for me on iOS but always goes trough in Android. The only solution i found is to do a react-native link only for iOS (renaming the android folder to something else), then do cd ios and pod install. After that, in the majority of the cases, it would work out of the box, while other libs needs still to be updated to have a full integration with RN 0.60.
Hope all this will be fixed soon but until that we only have to wait and hope that the libs work without any other complications