[Solved] Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'

React Native Mohit Mozumder

Problem:

As ViewPropTypes has been removed from 'react-native' and the packages using it didn't update. I am facing the following error-

ERROR  Invariant Violation: ViewPropTypes has been removed from React 
Native. Migrate to ViewPropTypes exported from 
'deprecated-react-native-prop-types'.


Solution:

follow the below steps-

At first Run the command in the terminal

npm i deprecated-react-native-prop-types@2.2.0

then go to the node modules and find the module that you are using. Next Navigate into the "src" folder of the module file and look for

 import {
      findNodeHandle,
      Platform,
      NativeModules,
      ViewPropTypes,
      requireNativeComponent,
      View,
      ActivityIndicator,
      Text,
      StyleSheet,
      PermissionsAndroid,
    } from 'react-native';

In the following code remove the ViewPropTypes and paste the following command below this

import { ViewPropTypes } from 'deprecated-react-native-prop-types';

save the file and run it again. Hopefully problem will be fixed.


Thank you for reading the article. If you face any further problem feel free to contact us.