Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active August 12, 2019 16:08
Show Gist options
  • Select an option

  • Save duytq94/b446a5fc0e4d2dc613e4c7bdd8005cc4 to your computer and use it in GitHub Desktop.

Select an option

Save duytq94/b446a5fc0e4d2dc613e4c7bdd8005cc4 to your computer and use it in GitHub Desktop.
componentDidMount() {
this.checkLogin()
}
checkLogin = () => {
if (!localStorage.getItem(AppString.ID)) {
this.setState({
isLoading: false
}, () => {
this.props.history.push('/')
})
} else {
this.getListUser()
}
}
getListUser = async () => {
const result = await myFirestore.collection(AppString.NODE_USERS).get()
if (result.docs.length > 0) {
this.listUser = [...result.docs]
this.setState({
isLoading: false
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment