react-native-themed-styles
react-native-themed-styles copied to clipboard
Type error in strict mode
Hi,
thanks for the package, love the approach. I'm using it with TypeScript in strict
mode. When I follow your example and use createStyles
I get a type error at theme
:
Parameter 'theme' implicitly has an 'any' type.
export default createStyles(theme => ({
container: {
backgroundColor: theme.backgroundColor,
flex: 1
},
}))
I've fixed it by assigning a type each time:
type ThemeValues = { [identifier: string ]: number | string };
export default createStyles((theme: ThemeValues) => ({
container: {
backgroundColor: theme.backgroundColor,
flex: 1
},
}))
Another error happens when using the hook to get the styles:
const Container: React.FC<IContainer> = ({ children }) => {
const [ styles ] = useTheme(themedStyles);
return (
<View style={styles.container}>
{children}
</View>
);
}
Property 'container' does not exist on type 'NamedStyles<NamedStyles
> | NamedStyles<NamedStyles >'. Property 'container' does not exist on type 'NamedStyles<NamedStyles >'.
I'm not the most advanced TypeScript user yet so I wonder if this could be fixed in the library directly.