Search code examples
react-nativereact-native-web

How to generate class names instead of inline styles for react-native-web?


I'm running expo web build which uses react-native-web. I noticed it generates inline styles so if I render a list of items, the styles get repeated for each item. Is there a way to make it generate a unique className instead and add to the head like styled-components?


Solution

  • Revisited this and realized it's because the components I was using did not use the StyleSheet.create api call internally, which WILL generate atomic css classes on react-native-web. Setting a regular object as the style property will just generate inline styles. For more info, see the issue I posted here:

    https://github.com/akveo/react-native-ui-kitten/issues/1266