Skip to content

Conversation

lorstenoplo
Copy link
Contributor

Added two new hooks for sign In and Register

  1. Created a function that you can call to start the process
  2. loading, credential, error params provided
  3. Updated readme to show implementation of new hooks and one complete example

Should Close: #85 , close: #46 , close: #43

@lorstenoplo
Copy link
Contributor Author

lorstenoplo commented Jan 6, 2021

@chrisbianca I have fixed auth hook issues by adding two new hooks to check the case when the users logins or signs up for the first time.
Please check if this PR can be merged as it can solve 3 open issues that I have mentioned.

@slk333
Copy link

slk333 commented Jan 26, 2021

@chrisbianca any update on this ?

Copy link
Contributor

@chrisbianca chrisbianca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lorstenoplo thank you for the submission and apologies for the delay in reviewing this properly. I've added a few suggested changes to the PR, which I'm very happy to make myself if you don't have the time, but wanted to highlight the suggestions before doing that. They're only minor and just to ensure consistency across the hooks.

Let me know either way and we can get this merged and released.


export default (
auth: firebase.auth.Auth,
email: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to make email and password variables that are passed into the returned login function. This is more in keeping with what some of the other libraries that allow mutation of data, e.g. apollo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I was thinking about the exact same thing


export default (
auth: firebase.auth.Auth,
email: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, I think it would be better to make email and password variables that are passed into the returned register function

});
};

const resArray: loginHook = [loggedInUser, error, login, loading];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a return perspective, I think that the function should be returned as the first item in the array and the order of the other elements should match the order of useAuthState.

So it should be: [login, loggedInUser, loading, error]

});
};

const resArray: registerHook = [registeredUser, error, register, loading];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, the ordering should match what's proposed for login

@lorstenoplo
Copy link
Contributor Author

The thing is I have no time ( exams ).
If you don't mind can you make those changes yourself.

I could have made those changes but I don't want to make mistakes ( as I have exams = tension )

@chrisbianca
Copy link
Contributor

No problem at all. I'll get this merged and then make the changes. Thanks again for the PR and good luck with your exams!

@chrisbianca chrisbianca merged commit 0aba3cd into CSFrequency:master Feb 27, 2021
chrisbianca added a commit that referenced this pull request Feb 27, 2021
@chrisbianca
Copy link
Contributor

@lorstenoplo just FYI, I also updated the names of the hooks to better match the functionality that they were implementing. This means that we could add wider support for underlying authentication methods in the future.

This has now been released in https://github.com/CSFrequency/react-firebase-hooks/releases/tag/v3.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

loading and error not working on Auth Hook initialising and error not working on Auth Hook Uncaught auth error
3 participants