From 8bde1e6b812022eda93d9d48067845f12f99884b Mon Sep 17 00:00:00 2001 From: Kyle Gill Date: Sun, 19 May 2019 19:34:03 -0600 Subject: [PATCH] fix: wrap development errors in auth changes --- src/components/session/withAuthentication.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/session/withAuthentication.js b/src/components/session/withAuthentication.js index 94f3b29..fdef9e1 100644 --- a/src/components/session/withAuthentication.js +++ b/src/components/session/withAuthentication.js @@ -21,13 +21,15 @@ const withAuthentication = Component => { this.listener = this.props.firebase.auth.onAuthStateChanged( authUser => { localStorage.setItem("authUser", JSON.stringify(authUser)) - this.setState({ - authUser: { - uid: authUser.uid, - email: authUser.email, - emailVerified: authUser.emailVerified, - }, - }) + if (authUser) { + this.setState({ + authUser: { + uid: authUser.uid, + email: authUser.email, + emailVerified: authUser.emailVerified, + }, + }) + } }, () => { localStorage.removeItem("authUser")