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

StyleSheet object type?

$
0
0

So I've been trying to pass created StyleSheet object as a function argument. This is working fine so far but as I'm using TypeScript I want to give that argument a proper type and that's were my pain begins. I've already tried to create StyleSheet with my Type but that's not a case as I want it to be completely universal.

const useStyles = (mainStyles, iosStyles?, androidStyles?) => {    const [defaultStyles, setDefaultStyles] = useState(mainStyles)    const [platformStyles, setPlatformStyles] = useState(      Platform.OS === 'ios' ? iosStyles : androidStyles)  if (!iosStyles && !androidStyles) {      const mergedStyles = StyleSheet.create({ ...defaultStyles })      return mergedStyles    }  const mergedStyles = StyleSheet.create({      ...defaultStyles,      ...platformStyles    })    return mergedStyles  }

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>