Ranko Koturic
Ranko Koturic

Reputation: 127

I'm gettin error default.storage is not a function when i run my react app

I'm trying to implement adding images feature in my react project with usage of firebase storage. This is the error: Uncaught TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_3__.default.storage is not a function. This error occurs in firebase configuration file. I used firebase firestore in this project for adding new blogs, and I was adding images through url and everything worked just fine.

Here are my imports:

import firebase from 'firebase/compat/app';
import "firebase/storage"

And instance of storage

export const storage = firebase.storage()

Upvotes: 2

Views: 779

Answers (2)

Affan
Affan

Reputation: 11

If you are an expo user importing firebase from compat/storage solves the issue

import firebase from 'firebase/compat/app';

Upvotes: 1

samthecodingman
samthecodingman

Reputation: 26171

When using the compatibility library, make sure that all components are imported from the compatibility library.

import firebase from 'firebase/compat/app';
import "firebase/compat/storage";
//               ^^^^^^

The compatibility library is for supporting legacy code. For all new code, you should be using the modern Modular SDK because the legacy Namespaced SDK is deprecated. See the upgrade guide for details.

Upvotes: 1

Related Questions