Fixed account list issue

This commit is contained in:
Mustafa Buyukcelebi 2019-02-13 18:07:03 +03:00
parent caabda2e48
commit b30d216f38

View File

@ -29,28 +29,27 @@ class SideMenuContainer extends Component {
}
// Component Life Cycle Functions
componentWillMount() {
const { otherAccounts } = this.props;
this._createUserList(otherAccounts);
}
componentWillReceiveProps(nextProps) {
const { otherAccounts, isLoggedIn } = this.props;
const { isLoggedIn } = this.props;
if (isLoggedIn && otherAccounts !== nextProps.otherAccounts) {
if (isLoggedIn) {
this._createUserList(nextProps.otherAccounts);
}
}
_createUserList = (otherAccounts) => {
const { currentAccount } = this.props;
const accounts = [];
otherAccounts.forEach((element) => {
accounts.push({
name: `@${element.username}`,
username: element.username,
id: element.username,
});
if (element.username !== currentAccount.name) {
accounts.push({
name: `@${element.username}`,
username: element.username,
id: element.username,
});
}
});
accounts.push({
name: 'Add Account',
@ -96,7 +95,7 @@ class SideMenuContainer extends Component {
render() {
const { currentAccount, isLoggedIn } = this.props;
const { accounts } = this.state;
console.log('this.props.otherAccounts :', this.props.otherAccounts);
return (
<SideMenuView
navigateToRoute={this._navigateToRoute}