Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type styles

$
0
0

It complains:Element implicitly has an 'any' type because expression of type 'string' can't be used to index type styles

type props = {  type: string}const style = styles[props.type]const styles = StyleSheet.create({  base: {    ...spacing.medium,    padding: 10,    textAlign: "center",    textAlignVertical: "center",    fontWeight: "bold",    fontSize: 18,    height: 50,  },  primary: {    backgroundColor: colors.purple,    color: colors.white,  },  secondary: {    backgroundColor: "transparent",    color: colors.purple,    borderColor: colors.purple,    borderWidth: 2,  },}

Viewing all articles
Browse latest Browse all 6287

Trending Articles