{"id":10732,"library":"deprecated-react-native-prop-types","title":"Deprecated React Native PropTypes","description":"This package provides access to `propTypes` definitions that were formerly exposed directly by React Native components (e.g., `Image.propTypes`, `Text.propTypes`, `TextInput.propTypes`) and global `PropType` definitions (e.g., `ColorPropType`, `ViewPropTypes`, `EdgeInsetsPropType`, `PointPropType`). React Native itself removed these direct exports, encouraging developers to migrate to type-checking libraries like TypeScript or the general `prop-types` package for component validation. This package serves as a compatibility layer for older codebases that still rely on these specific `propTypes` definitions, facilitating a phased migration away from the deprecated patterns. The current stable version is 5.0.0. As a bridge for deprecated features, its release cadence is primarily tied to critical bug fixes or specific React Native migration paths rather than active feature development. Its key differentiator is solely to provide backward compatibility for legacy React Native projects that have not yet fully migrated.","status":"maintenance","version":"5.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/facebook/react-native-deprecated-modules","tags":["javascript"],"install":[{"cmd":"npm install deprecated-react-native-prop-types","lang":"bash","label":"npm"},{"cmd":"yarn add deprecated-react-native-prop-types","lang":"bash","label":"yarn"},{"cmd":"pnpm add deprecated-react-native-prop-types","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Modern React Native projects primarily use ES Modules. CommonJS `require` syntax might lead to issues in some environments or bundlers if not configured correctly. This specific prop type was previously available directly on the `Image` component in React Native.","wrong":"const { ImagePropTypes } = require('deprecated-react-native-prop-types');","symbol":"ImagePropTypes","correct":"import { ImagePropTypes } from 'deprecated-react-native-prop-types';"},{"note":"`ViewPropTypes` was moved out of `react-native` into this package starting with React Native 0.44. Attempting to import it directly from `react-native` in newer versions will fail. Ensure you are using a bundler that supports ESM for proper resolution.","wrong":"import { ViewPropTypes } from 'react-native'; // Incorrect since RN 0.44","symbol":"ViewPropTypes","correct":"import { ViewPropTypes } from 'deprecated-react-native-prop-types';"},{"note":"`ColorPropType` was deprecated and moved to this package from `react-native` starting with React Native 0.49. Ensure your bundler is configured for tree-shaking if you are only importing specific `propTypes`.","wrong":"import { ColorPropType } from 'react-native'; // Incorrect since RN 0.49","symbol":"ColorPropType","correct":"import { ColorPropType } from 'deprecated-react-native-prop-types';"}],"quickstart":{"code":"import { ImagePropTypes, ViewPropTypes, ColorPropType } from 'deprecated-react-native-prop-types';\nimport PropTypes from 'prop-types'; // The standard prop-types library\n\n// Define a React Native component or a higher-order component that still relies on these deprecated propTypes.\n// In a real application, this would typically be within a class component's `static propTypes` definition.\nconst MyLegacyComponent = ({ imageSource, containerStyle, highlightColor }) => {\n  // React automatically validates props against `propTypes` when the component renders.\n  // For demonstration, we'll just log the types.\n  console.log('Accessing ImagePropTypes structure:', ImagePropTypes);\n  console.log('Accessing ViewPropTypes style definition:', ViewPropTypes.style);\n  console.log('Accessing ColorPropType definition:', ColorPropType);\n\n  // You can combine these with standard prop-types\n  const combinedPropTypes = {\n    imageSource: ImagePropTypes, // This provides the full Image.propTypes structure\n    containerStyle: ViewPropTypes.style, // Specific style prop type\n    highlightColor: ColorPropType,\n    message: PropTypes.string.isRequired,\n  };\n\n  console.log('Combined propTypes object:', combinedPropTypes);\n\n  return null; // A minimal component for illustration\n};\n\n// Assign the propTypes to your component for React's validation system\nMyLegacyComponent.propTypes = {\n  imageSource: ImagePropTypes, // For props that expect the shape of Image.propTypes\n  containerStyle: ViewPropTypes.style, // For props that expect React Native style objects\n  highlightColor: ColorPropType, // For props that expect a color string or number\n  message: PropTypes.string.isRequired,\n};\n\nconsole.log('MyLegacyComponent.propTypes successfully assigned.');\n","lang":"typescript","description":"Demonstrates how to import and assign deprecated React Native `propTypes` (like `ImagePropTypes`, `ViewPropTypes.style`, and `ColorPropType`) to a component's `propTypes` object for backward compatibility in a TypeScript environment."},"warnings":[{"fix":"For React Native versions 0.44 and higher, you must explicitly install and import from `deprecated-react-native-prop-types` for these specific `propTypes`. The recommended long-term solution is to migrate to TypeScript or use the standalone `prop-types` library with custom type definitions.","message":"Direct exposure of `propTypes` on React Native components (e.g., `Image.propTypes`) and global `PropType` definitions (e.g., `ViewPropTypes`) was removed from the `react-native` package itself.","severity":"breaking","affected_versions":">=0.44.0 of react-native"},{"fix":"Plan a migration path for your codebase to use modern type-checking solutions like TypeScript for type safety or the standard `prop-types` library with explicit shape definitions where necessary. This package should be considered a temporary stop-gap.","message":"This package exists to bridge legacy code and its usage signifies reliance on deprecated patterns within the React Native ecosystem. It is not intended for new development.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Always install and use the standard `prop-types` package (`import PropTypes from 'prop-types';`) in conjunction with this library if you need general prop type validators (like `string`, `number`, `array`, `shape`). This package only provides the specific `PropType` objects that were extracted from React Native.","message":"This package is not a general replacement for the `prop-types` library. It specifically provides the *definitions* that were removed from React Native, such as `ViewPropTypes` or `ImagePropTypes`, not the `PropTypes` object itself (e.g., `PropTypes.string`).","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Import `ImagePropTypes` or `TextPropTypes` from `deprecated-react-native-prop-types` instead: `import { ImagePropTypes } from 'deprecated-react-native-prop-types';`","cause":"Attempting to access `Image.propTypes` or `Text.propTypes` directly on React Native components in versions where they have been removed.","error":"TypeError: Cannot read properties of undefined (reading 'propTypes')"},{"fix":"Install the package (`npm install deprecated-react-native-prop-types`) and import it: `import { ViewPropTypes } from 'deprecated-react-native-prop-types';`","cause":"Trying to use `ViewPropTypes` after upgrading React Native without installing and importing it from the `deprecated-react-native-prop-types` package.","error":"ReferenceError: ViewPropTypes is not defined"}],"ecosystem":"npm"}