Skip to content

Commit

Permalink
use StyleSheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Ne3l committed Sep 11, 2022
1 parent 9aadf0e commit e8e6c9b
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import prettyFormat, { plugins } from 'pretty-format';
import type { ReactTestInstance } from 'react-test-renderer';
import type { Falsy, TextStyle, ViewStyle } from 'react-native';
import { StyleSheet } from 'react-native';

const { ReactTestComponent, ReactElement } = plugins;

Expand Down Expand Up @@ -118,23 +119,7 @@ type StyleRecord = {
function getStylePropAsRecord(styles: Falsy | Object | Object[]): StyleRecord {
if (!styles) return {};

if (Array.isArray(styles)) {
const flatStyles = styles.flat();
let result = {};

for (const styleItem of flatStyles) {
const entries = Object.entries(styleItem);

for (const [key, value] of entries) {
// @ts-ignore how to type it?
result[key] = value;
}
}

return result;
}

return styles as StyleRecord;
return StyleSheet.flatten(styles);
}

function isEmpty(value: unknown) {
Expand Down

0 comments on commit e8e6c9b

Please sign in to comment.