Skip to content

Commit 617b438

Browse files
itsramielnecolas
authored andcommitted
[fix] Only stringify numeric aspectRatio
Close #2561
1 parent 213b616 commit 617b438

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

packages/react-native-web/src/exports/StyleSheet/__tests__/preprocess-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ describe('StyleSheet/preprocess', () => {
9999
expect(preprocess({ aspectRatio: 9 / 16 })).toEqual({
100100
aspectRatio: '0.5625'
101101
});
102+
103+
expect(preprocess({ aspectRatio: '0.5' })).toEqual({
104+
aspectRatio: '0.5'
105+
});
106+
107+
expect(preprocess({ aspectRatio: undefined })).toEqual({});
102108
});
103109

104110
test('fontVariant', () => {

packages/react-native-web/src/exports/StyleSheet/preprocess.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export const preprocess = <T: {| [key: string]: any |}>(
182182
continue;
183183
}
184184

185-
if (prop === 'aspectRatio') {
185+
if (prop === 'aspectRatio' && typeof value === 'number') {
186186
nextStyle[prop] = value.toString();
187187
} else if (prop === 'fontVariant') {
188188
if (Array.isArray(value) && value.length > 0) {

packages/react-native-web/src/types/styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export type LayoutStyles = {|
188188
| 'flex-start'
189189
| 'stretch'
190190
),
191-
aspectRatio?: ?number,
191+
aspectRatio?: ?NumberOrString,
192192
backfaceVisibility?: ?VisiblilityValue,
193193
borderWidth?: ?DimensionValue,
194194
borderBlockWidth?: ?DimensionValue,

0 commit comments

Comments
 (0)