prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

linkAndRetrieveDataWithCredential, linkWithPopup, and linkWithRedirect aren't included in the extended firebase instance #1010

Open Ruborcalor opened 3 years ago

Ruborcalor commented 3 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

linkAndRetrieveDataWithCredential, linkWithPopup, and linkWithRedirect are all included in src/actions/auth.js, but they cannot be called from the extended firebase instance.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.

this.props.firebase.linkWithPopup(provider) gives "TypeError: this.props.firebase.linkWithPopup is not a function".

What is the expected behavior?

this.props.firebase.linkWithPopup(provider) should call linkWithPopup from src/actions/auth.js.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

I am using react-redux-firebase version 3.7.0.

Related Issues

473

Workaround

I am currently using the following as a workaround:

    this.props.firebase
      .auth()
      .currentUser.linkWithPopup(facebookProvider)
      .then((result) => {
        const credential = result.credential;
        const user = result.user;
        console.log(`Account successfully linked: ${user}`);
        this.props.dispatch({
          type: "@@reactReduxFirebase/AUTH_LINK_SUCCESS",
          payload: result.user,
        });
        this.props.firebase.login({
          credential,
        });
      })
      .catch((error) => {
        console.log("Error upgrading anonymous account", error);
        this.props.firebase.login({
          credential: error.credential,
        });
      })