diff --git a/packages/react-native-web/src/exports/StyleSheet/__tests__/preprocess-test.js b/packages/react-native-web/src/exports/StyleSheet/__tests__/preprocess-test.js index 9b03a7772e..06bfd14d24 100644 --- a/packages/react-native-web/src/exports/StyleSheet/__tests__/preprocess-test.js +++ b/packages/react-native-web/src/exports/StyleSheet/__tests__/preprocess-test.js @@ -99,6 +99,12 @@ describe('StyleSheet/preprocess', () => { expect(preprocess({ aspectRatio: 9 / 16 })).toEqual({ aspectRatio: '0.5625' }); + + expect(preprocess({ aspectRatio: '0.5' })).toEqual({ + aspectRatio: '0.5' + }); + + expect(preprocess({ aspectRatio: undefined })).toEqual({}); }); test('fontVariant', () => { diff --git a/packages/react-native-web/src/exports/StyleSheet/preprocess.js b/packages/react-native-web/src/exports/StyleSheet/preprocess.js index 4b3d1487a4..e9b4d366e5 100644 --- a/packages/react-native-web/src/exports/StyleSheet/preprocess.js +++ b/packages/react-native-web/src/exports/StyleSheet/preprocess.js @@ -182,7 +182,7 @@ export const preprocess = ( continue; } - if (prop === 'aspectRatio') { + if (prop === 'aspectRatio' && typeof value === 'number') { nextStyle[prop] = value.toString(); } else if (prop === 'fontVariant') { if (Array.isArray(value) && value.length > 0) { diff --git a/packages/react-native-web/src/types/styles.js b/packages/react-native-web/src/types/styles.js index 296a2abf2f..4f02e84e36 100644 --- a/packages/react-native-web/src/types/styles.js +++ b/packages/react-native-web/src/types/styles.js @@ -188,7 +188,7 @@ export type LayoutStyles = {| | 'flex-start' | 'stretch' ), - aspectRatio?: ?number, + aspectRatio?: ?NumberOrString, backfaceVisibility?: ?VisiblilityValue, borderWidth?: ?DimensionValue, borderBlockWidth?: ?DimensionValue,