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

**URL:** https://sentry.io/answers/viewproptypes-will-be-removed-from-react-native-migrate-to-viewproptypes-exported-from-deprecated-react-native-prop-types/

---

## The Problem

When running your React Native application, you may get the following warning:

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

You may also receive the message as an error:

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

## The Solution

Because React Native started removing the `PropTypes` API from version 0.66 onward, an import of `PropTypes` results in a deprecation warning.

React Native recommends that you use a type system, such as TypeScript, instead of `PropTypes`.

If you need runtime type checking, you can use TypeScript type guards to narrow types down to one specific type at runtime. A library such as [`tiny-invariant`](https://www.npmjs.com/package/tiny-invariant) can further simplify type narrowing.

If you still need to use `PropTypes`, install the [`deprecated-react-native-prop-types`](https://www.npmjs.com/package/deprecated-react-native-prop-types/v/2.2.0) npm package and import the deprecated `PropTypes` from `deprecated-react-native-prop-types` instead of `react-native`.

* In other words, you will encounter deprecation warnings and errors when you use the following import:

  ```js
  import { ViewPropTypes } from 'react-native';
  ```

* But if you install the `deprecated-react-native-prop-types` npm package, you can use the following import as a workaround:

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

If you aren't using `Proptypes`, and the warning or error is caused by a dependency, check whether the latest version of the library has fixed the issue.

If your version of the library is already up to date or the latest version hasn't fixed the imports, submit an issue or pull request to the library.

As a last resort, you can fix the imports in the dependencies yourself. You can use a library such as [`patch-package`](https://www.npmjs.com/package/patch-package) to simplify fixing the imports until they are fixed by the library.

### Note on the History of `PropTypes` in React

In 2017, React version 15.5 moved the built-in `PropTypes` to a separate package, because static type checking with TypeScript is used more often than `PropTypes` in modern React. 

React Native started to remove the `PropTypes` API in 2018.

In 2021, a deprecation warning for using `PropTypes` was included in the release of React Native version 0.66.

In React Native version 0.68, `PropTypes` was removed. 

React Native restored `PropTypes` in version 0.71 for two reasons: 

* Developers needed more time to upgrade to the latest React Native version and migrate their code to avoid using `PropTypes`.
* There were some issues that prevented developers from fixing the `PropTypes` depreciation warning. 

In React Native version 0.74, the deprecated `PropTypes` was removed again.

---

*Source: [sentry.io/answers/viewproptypes-will-be-removed-from-react-native-migrate-to-viewproptypes-exported-from-deprecated-react-native-prop-types/](https://sentry.io/answers/viewproptypes-will-be-removed-from-react-native-migrate-to-viewproptypes-exported-from-deprecated-react-native-prop-types/)*
