react-native-web-linear-gradient provides a web-compatible implementation of `react-native-linear-gradient` for use in React Native for Web projects. It allows developers to render linear gradients on the web using standard CSS gradients, effectively bridging the gap for a common UI component across native and web platforms. The current stable version is 1.1.2. The package follows an active maintenance release cadence, addressing compatibility issues and adding prop support as needed. Its key differentiator is providing a drop-in replacement via webpack aliasing, allowing a single codebase to use `react-native-linear-gradient` and automatically resolve to the web-specific implementation when bundled for the web. It maintains API compatibility with its native counterpart, simplifying cross-platform development.
npm install react-native-web-linear-gradientVerified import paths — ran on the pinned version, not inferred.
Demonstrates installation, the required webpack alias configuration, and basic usage of the LinearGradient component to display a simple gradient on the web.
Avoid using the `angleCenter` prop. For controlling gradient direction, rely on `start` and `end` props.
Upgrade to version 1.1.2 or higher to ensure `onLayout` prop is passed through and functions as expected.
Ensure your `webpack.config.js` or equivalent build configuration includes the specified alias under `resolve.alias`.
Add or correct the alias in your webpack configuration: `resolve: { alias: { 'react-native-linear-gradient': 'react-native-web-linear-gradient' } }`.Ensure the `colors` array passed to the `LinearGradient` component has at least two hexadecimal or named color strings.
Verify that your webpack alias for `react-native-linear-gradient` is correctly set up to redirect to `react-native-web-linear-gradient`.