Skip to content

Commit

Permalink
Fixes Icon (#2804)
Browse files Browse the repository at this point in the history
  • Loading branch information
Srishti-Sharma authored and sankhadeeproy007 committed Jul 23, 2019
1 parent 9fcab56 commit 805577d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/basic/IconNB.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connectStyle } from 'native-base-shoutem-theme';
import { get } from 'lodash';
import AntDesign from 'react-native-vector-icons/AntDesign';
import Entypo from 'react-native-vector-icons/Entypo';
import EvilIcons from 'react-native-vector-icons/EvilIcons';
Expand All @@ -22,18 +23,19 @@ class IconNB extends Component {
theme: PropTypes.object
};

componentDidMount() {
this.setIcon(this.props.type);
constructor(props) {
super(props);
this.setIcon(props.type);
}

componentDidUpdate(nextProps) {
componentWillUpdate(nextProps) {
if (nextProps.type && this.props.type !== nextProps.type) {
this.setIcon(nextProps.type);
}
}

setIcon(iconType) {
if (iconType === undefined && this.context.theme) {
if (iconType === undefined && get(this, 'context.theme')) {
// eslint-disable-next-line
iconType = this.context.theme['@@shoutem.theme/themeStyle'].variables
.iconFamily;
Expand Down

1 comment on commit 805577d

@nismaxim82
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2832 bug fix

componentWillUpdate don't called, so it don't apply changed iconFamily and always apply default Ionicons.

Possible fix is to remove lifecycle function componentWillUpdate and add function componentWillMount

componentWillMount() { this.setIcon(this.props.type); }

Please sign in to comment.