aykutkardas / react-icomoon

It makes it very simple to use SVG icons in your React and React-Native projects.
https://svgps.app
MIT License
216 stars 22 forks source link

RNWeb: The style props works only with Inline style #23

Closed karthick-t2s closed 2 years ago

karthick-t2s commented 2 years ago

In RNWeb, The style property works only as an inline style. It didn't work if it's passed as an object from StyleSheet.create({})

Here is an expo link, switch to web tab and see the issue. working fine in iOS & Android

https://snack.expo.dev/@heykarthick/react-icomoon

import * as React from 'react';
import { View, StyleSheet } from 'react-native';

import Icon from './components/Icon';
const styles = StyleSheet.create({
  iconStyle: {
    color: 'red',
    margin: 20,
  },
});
export default function App() {
  return (
    <View>
      <Icon icon="pencil" size={100} style={styles.iconStyle} /> {/* didn't work */}
      <Icon icon="pencil" size={100} style={{ color: 'red', margin: 20 }} /> {/*Works*/}
    </View>
  );
}
aykutkardas commented 2 years ago

You're right. I will work on it. Thanks for your feedback.

karthick-t2s commented 2 years ago

Hey, thanks, and please note that the array of styles is also not working for the web.
eg: style={[styles.defaultStyle,styles.customStyle]}

aykutkardas commented 2 years ago

Hey, thanks, and please note that the array of styles is also not working for the web. eg: style={[styles.defaultStyle,styles.customStyle]}

Why not just use it as an object?

const styles = {
  iconStyle: {
    margin: 50,
    color: 'red',
  },
};

For Expo, this usage may be the exception.