Guest User

Untitled

a guest
Jun 9th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import React from 'react'
  2. import firebase from 'firebase'
  3.  
  4. class MyComponent extends React.Component {
  5. componentDidMount () {
  6. this.unsubscribe = firebase.auth().onAuthStateChanged(user => {
  7. this.setState(user)
  8. })
  9. }
  10.  
  11. componentWillUnmount () {
  12. this.unsubscribe()
  13. }
  14.  
  15. render () {
  16. if (!this.state.user) return <p>You're not logged in!</p>
  17. return <p>Hello, {this.state.user.email}</p>
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment