Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-[RCTRootView cancelTouches]` is deprecated and will be deleted soon in react native map

I am using react-native-map and it works well on ios and android.

my react native version is 0.61.2. But in ios, when I click map, then shows warning "-[RCTRootView cancelTouches]` is deprecated and will be deleted soon.".

What is this and how to remove this warning?

like image 321
Water Flower Avatar asked Oct 03 '19 23:10

Water Flower


2 Answers

See this commit which is now in react-native 0.61+

Although it says deprecated, according to the conversation in this pull request it will be added back to react-native core.

You can dismiss it till the react-native team removes the warning:

console.ignoredYellowBox = ['Warning: `-[RCTRootView cancelTouches]`'];

Or you downgrade react-native to a version below 0.61.

Some libraries like react-native-gesture-handler still call the cancelTouches method. Thats why u see this warning.

I was using react-native-gesture-handler which gave this warning on debug mode and caused crashes in release builds on both android and ios. Fixed the crashes by adding import 'react-native-gesture-handler' at the top level of index.js.

like image 144
Muhammed B. Aydemir Avatar answered Sep 26 '22 03:09

Muhammed B. Aydemir


Muhammed's answer is mostly correct, however in order to stop crashes you also need to wrap the App in the React Native Gesture Handler HOC as follows:

index.js

import 'react-native-gesture-handler'
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';

index.js

AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(App));

Note You must have these imports as the very first imports for the fix to work.

This is true for React Native 61.2 and react-native-gesture-handler 1.4.1

Note: The official React Native docs suggest using the YellowBox module to ignore the warnings as. For example:

import {YellowBox} from 'react-native';

YellowBox.ignoreWarnings(['`-[RCTRootView cancelTouches]`']);
like image 40
MrNickel Avatar answered Sep 24 '22 03:09

MrNickel