Closed
Description
Description
You can no longer pass multiple style arrays down as props e.g
// AlertText.tsx
import React, { forwardRef } from 'react';
import { Text, TextProps } from 'react-native';
import { useAlertContext } from './Alert.context';
import { StyleSheet } from 'react-native-unistyles';
const AlertText = forwardRef<Text, TextProps & { semibold?: boolean }>(
({ children, semibold = false, ...props }, ref) => {
const { colorScheme } = useAlertContext();
styles.useVariants({ colorScheme, semibold });
return (
<Text ref={ref} {...props} style={[styles.text, props.style]}>
{children}
</Text>
);
}
);
AlertText.displayName = 'AlertText';
const styles = StyleSheet.create(theme => ({
text: {
fontFamily: theme.fonts.body,
fontWeight: theme.fontWeights.normal,
fontSize: theme.fontSizes.md,
lineHeight: theme.lineHeights.lg,
flexShrink: 1,
variants: {
semibold: {
true: {
fontWeight: theme.fontWeights.semibold,
},
},
colorScheme: {
cyan: {
color: theme.colors.cyan900,
},
red: {
color: theme.colors.red900,
},
green: {
color: theme.colors.green900,
},
gold: {
color: theme.colors.gold900,
},
},
},
},
}));
export default AlertText;
// AlertTitle.tsx
import React, { forwardRef } from 'react';
import type { Text, TextProps } from 'react-native';
import { StyleSheet } from 'react-native-unistyles';
import AlertText from './AlertText';
const AlertTitle = forwardRef<Text, TextProps>(({ children, ...props }, ref) => {
return (
<AlertText ref={ref} {...props} style={[styles.text, props.style]}>
{children}
</AlertText>
);
});
AlertTitle.displayName = 'AlertTitle';
const styles = StyleSheet.create(theme => ({
text: {
fontWeight: theme.fontWeights.semibold,
},
}));
export default AlertTitle;
The styles from the parent title component are no longer applied.
Steps to Reproduce
- Add create a component with an array of styles e.g
[styles.component, props.style]
- Pass second array from parent component e.g
[styles.parent, props.style]
- See parent styles are not applied
Snack or Repository Link (Optional)
No response
Unistyles Version
3.0.0-beta.4
React Native Version
0.76.3
Platforms
Android, iOS
Expo
Yes
Metadata
Metadata
Assignees
Labels
No labels