NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Using different iconFamily gives warning, but displays correctly

Open sedders123 opened this issue 9 years ago • 8 comments

react-native, react and native-base version

  • React-Native: 0.40.0
  • React: 15.4.2
  • Native-Base: 2.0.5

Expected behaviour

Setting the iconFamily in variables will allow for other icons sets to be used.

Actual behaviour

Other iconSets can be used however there is a warning syaing that IconNB got an invalid prop type for name and then lists the IonIcon icon names.

Steps to reproduce (code snippet or screenshot)

import { Component } from 'react';
import { Container, StyleProvider, getTheme, Content, Icon } from 'native-base';

const variables={
  iconFamily: 'FontAwesome',
  iconFontSize: 28,
};

class TestPage extends Component {
  render() {
    return (
      <Container>
        <StyleProvider style={getTheme(variables)}>
          <Content>
            <Icon name="user" />
          </Content>
        </StyleProvider>
      </Container>
    );
  }
}

Screenshot of emulator/device

Icon displaying but still gives warning Expanded error message Stack trace

Is the bug present in both ios and android or in any one of them?

Can only test on Android

Any other additional info which would help us debug the issue quicker.

This is a follow up issue from #493

sedders123 avatar Feb 10 '17 09:02 sedders123

I gets problems. How to fix ???

iambanh2 avatar Feb 10 '17 10:02 iambanh2

Looking through the source, I think that the problem lies with this line of code:

https://github.com/GeekyAnts/NativeBase/blob/a1cdca9ad2a7406b76feea76959536688dc226c3/src/basic/IconNB.js#L60

Ionicons' proptypes are copied into IconNBs proptypes. This means that if a different icon set is used a warning will appear as the proptype is in fact invalid

sedders123 avatar Feb 10 '17 11:02 sedders123

Thanks, will be looked into!

sankhadeeproy007 avatar Feb 10 '17 12:02 sankhadeeproy007

Other than giving warnings, certain icons do not render with other FontFamilies. e.g. In place of FontAwesome, if you use 'MaterialIcons' and try to use menu icon, it won't render correctly.

In my opinion, the root of the cause is here: https://github.com/GeekyAnts/NativeBase/blob/a1cdca9ad2a7406b76feea76959536688dc226c3/src/basic/Icon/NBIcons.json

v15h9 avatar Feb 10 '17 13:02 v15h9

Just come across this issue as well. Was trying to use lock icon in FontAwesome. Should the getName function be changed to check for icon packs in variables?

https://github.com/GeekyAnts/NativeBase/blob/a1cdca9ad2a7406b76feea76959536688dc226c3/src/basic/Icon/index.js#L18-L35

sedders123 avatar Feb 10 '17 13:02 sedders123

Looks like this was fixed in https://github.com/GeekyAnts/NativeBase/commit/f6e9e8b9c1f51b36903bfcfb09838510ab73a29a.

Will keep issue open until the next release, but using master for now and it is working. Thanks 😃

sedders123 avatar Feb 13 '17 16:02 sedders123

Now that 2.0.6 has been released I'm closing this issue.

sedders123 avatar Feb 13 '17 16:02 sedders123

Thanks!

sankhadeeproy007 avatar Feb 13 '17 17:02 sankhadeeproy007