Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type Error undefined is not an object (evaluating 'Wu.getRandomValues')

This is the code I implemented for adding data to collection:

import FirebaseKeys from "./config";
import firebase from "firebase";
import "@firebase/firestore";

class Fire {
  constructor() {
    firebase.initializeApp(FirebaseKeys);
  }
  addPost = async ({ text, localUri }) => {
    const remoteUri = await this.uploadPhotoAsync(localUri);
    const desc = text;

    return new Promise((res, rej) => {
      // console.log("THIS FIRESTORE" + this.firestore);
      const dbh = firebase.firestore();

      // this.firestore.collection("posts").add({
      //     text: desc,
      //     uid: this.uid,
      //     timestamp: this.timestamp,
      //     image: remoteUri
      //   })

      dbh
        .collection("posts")
        .doc("feed")
        .set({
          text: desc,
          uid: this.uid,
          timestamp: this.timestamp,
          image: remoteUri
        })
        .then(ref => {
          res(ref);
          console.log("EVERYTHING IS FINE HERE");
        })
        .catch(error => {
          console.log("ERROR HERE TOO");

          rej(error);
        });
    });
  };

  uploadPhotoAsync = async uri => {
    console.log(this);

    const path = "Date.jpg";
    return new Promise(async (res, rej) => {
      const response = await fetch(uri);
      const file = await response.blob();

      let upload = firebase
        .storage()
        .ref(path)
        .put(file);
      upload.on(
        "state_changed",
        snapshot => {},
        err => {
          console.log("ERROR IN PHOTO UPLOAD");

          rej(err);
        },
        async () => {
          const url = await upload.snapshot.ref.getDownloadURL();
          res(url);
          console.log("IMAGE IS UPLOADING FINE");
        }
      );
    });
  };
  get firestore() {
    return firebase.firestore();
  }

  get uid() {
    return (firebase.auth().currentUser || {}).uid;
  }

  get timestamp() {
    return Date.now();
  }
}

Fire.shared = new Fire();
export default Fire;

I'm building an app using expo react native and using firebase for data manipulation. But while using function for adding data to collection, it shows error like

undefined is not an object (evaluating 'Wu.getRandomValues')

Help me out anyone

SCREENSHOT OF THE ERROR

like image 287
moh_it Avatar asked Mar 06 '26 01:03

moh_it


1 Answers

Update: the problem is being addressed here and should be fixed in v7.13.3. I previously stated that downgrading to firebase v7.9.0 fixed the issue. I discovered that the issue does not exist until v7.13.2. So we can downgrade to v7.13.1. However, we must completely uninstall firebase for this to work.

I experienced the same error with expo and firebase. I am using Expo version 37. To fix the problem I had to downgrade firebase using the following commands in my app's directory:

npm remove --save firebase 
npm install --save [email protected]

If I use firebase version 7.13.2 I get this error:

undefined is not an object (evaluating 'Wu.getRandomValues')

like image 72
blacKnight Avatar answered Mar 08 '26 14:03

blacKnight



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!