Skip to content

Commit

Permalink
Remove unnecessary try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
MvRemmerden committed Jun 28, 2024
1 parent d23c46c commit ed69ee7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
15 changes: 9 additions & 6 deletions src/__tests__/initFirebaseClientSDK.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ describe('initFirebaseClientSDK', () => {
expect.assertions(1)
const initFirebaseClientSDK = require('src/initFirebaseClientSDK').default
initFirebaseClientSDK()
expect(mockInitializeApp).toHaveBeenCalledWith({
apiKey: 'fakeAPIKey123',
authDomain: 'my-example-app.firebaseapp.com',
databaseURL: 'https://my-example-app.firebaseio.com',
projectId: 'my-example-app-id',
})
expect(mockInitializeApp).toHaveBeenCalledWith(
{
apiKey: 'fakeAPIKey123',
authDomain: 'my-example-app.firebaseapp.com',
databaseURL: 'https://my-example-app.firebaseio.com',
projectId: 'my-example-app-id',
},
undefined
)
})

it('does not call firebase.initializeApp if Firebase already has an initialized app', () => {
Expand Down
17 changes: 7 additions & 10 deletions src/useFirebaseUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,13 @@ const useFirebaseUser = () => {
}

// https://firebase.google.com/docs/reference/js/firebase.auth.Auth#onidtokenchanged
try {
const { firebaseClientAppName } = getConfig()
const app = getApp(firebaseClientAppName)
const unsubscribe = onIdTokenChanged(getAuth(app), onIdTokenChange)
return () => {
unsubscribe()
isCancelled = true
}
} catch (error) {
throw error

const { firebaseClientAppName } = getConfig()
const app = getApp(firebaseClientAppName)
const unsubscribe = onIdTokenChanged(getAuth(app), onIdTokenChange)
return () => {
unsubscribe()
isCancelled = true
}
}, [])

Expand Down

0 comments on commit ed69ee7

Please # to comment.