Registry / deprecated-react-native-prop-types

deprecated-react-native-prop-types

JSON →
library5.0.0jsnpmunverified

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.

npm install deprecated-react-native-prop-types
INSTALL
IMPORT
SIG · DEPRECATED-REACT-N
D
deprecated-react-native-prop-types
javascriptv5.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ImagePropTypes
✓ import { ImagePropTypes } from 'deprecated-react-native-prop-types';
✗ const { ImagePropTypes } = require('deprecated-react-native-prop-types');
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.
ViewPropTypes
✓ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
✗ import { ViewPropTypes } from 'react-native'; // Incorrect since RN 0.44
`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.
ColorPropType
✓ import { ColorPropType } from 'deprecated-react-native-prop-types';
✗ import { ColorPropType } from 'react-native'; // Incorrect since RN 0.49
`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`.

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.

import { ImagePropTypes, ViewPropTypes, ColorPropType } from 'deprecated-react-native-prop-types'; import PropTypes from 'prop-types'; // The standard prop-types library // Define a React Native component or a higher-order component that still relies on these deprecated propTypes. // In a real application, this would typically be within a class component's `static propTypes` definition. const MyLegacyComponent = ({ imageSource, containerStyle, highlightColor }) => { // React automatically validates props against `propTypes` when the component renders. // For demonstration, we'll just log the types. console.log('Accessing ImagePropTypes structure:', ImagePropTypes); console.log('Accessing ViewPropTypes style definition:', ViewPropTypes.style); console.log('Accessing ColorPropType definition:', ColorPropType); // You can combine these with standard prop-types const combinedPropTypes = { imageSource: ImagePropTypes, // This provides the full Image.propTypes structure containerStyle: ViewPropTypes.style, // Specific style prop type highlightColor: ColorPropType, message: PropTypes.string.isRequired, }; console.log('Combined propTypes object:', combinedPropTypes); return null; // A minimal component for illustration }; // Assign the propTypes to your component for React's validation system MyLegacyComponent.propTypes = { imageSource: ImagePropTypes, // For props that expect the shape of Image.propTypes containerStyle: ViewPropTypes.style, // For props that expect React Native style objects highlightColor: ColorPropType, // For props that expect a color string or number message: PropTypes.string.isRequired, }; console.log('MyLegacyComponent.propTypes successfully assigned.');
Debug
Known issues
breakingDirect 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.
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.
affects: >=0.44.0 of react-native
deprecatedThis 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.
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.
affects: >=0.0.0
gotchaThis 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`).
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.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'propTypes')
Attempting to access `Image.propTypes` or `Text.propTypes` directly on React Native components in versions where they have been removed.
fix
Import `ImagePropTypes` or `TextPropTypes` from `deprecated-react-native-prop-types` instead: `import { ImagePropTypes } from 'deprecated-react-native-prop-types';`
ReferenceError: ViewPropTypes is not defined
Trying to use `ViewPropTypes` after upgrading React Native without installing and importing it from the `deprecated-react-native-prop-types` package.
fix
Install the package (`npm install deprecated-react-native-prop-types`) and import it: `import { ViewPropTypes } from 'deprecated-react-native-prop-types';`
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
deprecated-react-native-prop-types — npm install deprecated-react-native-prop-types · libregistry