From b056c25d47a153c69f32c2a7e486da224008d280 Mon Sep 17 00:00:00 2001 From: Gustavo Bueno Date: Tue, 2 Oct 2018 12:04:56 +0200 Subject: [PATCH] update setstate with function --- app/screens/User/components/Profile.js | 2 +- app/screens/User/components/RepoList.js | 2 +- app/screens/User/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/screens/User/components/Profile.js b/app/screens/User/components/Profile.js index 7e5c3f4..de6bedd 100644 --- a/app/screens/User/components/Profile.js +++ b/app/screens/User/components/Profile.js @@ -13,7 +13,7 @@ export default class Profile extends Component { const {username} = this.props getUserData(username) .then(({user, orgs}) => { - this.setState({user, orgs}); + this.setState(state => ({ ...state, user, orgs })); }); } diff --git a/app/screens/User/components/RepoList.js b/app/screens/User/components/RepoList.js index dff456c..9612bc5 100644 --- a/app/screens/User/components/RepoList.js +++ b/app/screens/User/components/RepoList.js @@ -11,7 +11,7 @@ export default class RepoList extends Component { getRepos() { const {username} = this.props this.props.getRepos(username).then(repos => { - this.setState({repos}); + this.setState(state => ({ ...state, repos })); }); } diff --git a/app/screens/User/index.js b/app/screens/User/index.js index 85eb2b9..753cfa8 100644 --- a/app/screens/User/index.js +++ b/app/screens/User/index.js @@ -10,7 +10,7 @@ export default class User extends Component { } handleFilterUpdate = (filter) => { - this.setState({filter}) + this.setState(state => ({ ...state, filter })) } render() {