Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions packages/react-native/src/private/styles/composeStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/

import type {
ImageStyle,
TextStyle,
ViewStyle,
} from '../../../Libraries/StyleSheet/StyleSheet';
import type {StyleProp} from '../../../Libraries/StyleSheet/StyleSheetTypes';

/**
* Combines two styles such that `style2` will override any styles in `style1`.
* If either style is null or undefined, the other one is returned without
* allocating an array, saving allocations and enabling memoization.
*/
export default function composeStyles<
T: ViewStyle | ImageStyle | TextStyle,
U: T,
V: T,
>(style1: ?StyleProp<U>, style2: ?StyleProp<V>): ?StyleProp<T> {
export default function composeStyles<T, U: T, V: T>(
style1: ?U,
style2: ?V,
): ?(T | $ReadOnlyArray<T>) {
if (style1 == null) {
return style2;
}
Expand Down