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

你。 提交于 2021-02-11 12:36:50

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/63585152/how-to-generate-class-names-instead-of-inline-styles-for-react-native-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!