packages/eslint-plugin-expo/docs/rules/prefer-box-shadow.md
expo/prefer-box-shadow)React Native now supports a new web-like boxShadow API that provides a more consistent and powerful way to add shadows to components. This rule encourages the use of the new boxShadow property instead of the legacy shadow properties.
This rule aims to promote the use of the modern boxShadow API over the older shadow properties (shadowColor, shadowOffset, shadowOpacity, shadowRadius, elevation).
Note: boxShadow is a new web-like API, only available on the New Architecture. Outset shadows are only supported on Android 9+. Inset shadows are only supported on Android 10+.
Examples of incorrect code for this rule:
const styles = StyleSheet.create({
container: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
},
});
Examples of correct code for this rule:
const styles = StyleSheet.create({
container: {
boxShadow: '0px 2px 3.84px rgba(0, 0, 0, 0.25)',
},
});