Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase API called outside injection context #3605

Open
EthanSK opened this issue Jan 2, 2025 · 2 comments
Open

Firebase API called outside injection context #3605

EthanSK opened this issue Jan 2, 2025 · 2 comments

Comments

@EthanSK
Copy link
Contributor

EthanSK commented Jan 2, 2025

Getting this console warning everywhere in my app thats using firebase, even within injection contexts

here are my deps

"@angular/animations": "~19.0.0",
    "@angular/cdk": "~19.0.2",
    "@angular/common": "~19.0.0",
    "@angular/compiler": "~19.0.0",
    "@angular/core": "~19.0.0",
    "@angular/fire": "19.0.0-rc.4",
    "@angular/forms": "~19.0.0",
    "@angular/material": "~19.0.2",
    "@angular/platform-browser": "~19.0.0",
    "@angular/platform-browser-dynamic": "~19.0.0",
    "@angular/platform-server": "~19.0.0",
    "@angular/router": "~19.0.0",
    "@angular/ssr": "~19.0.0",
    "@nestjs/axios": "^3.1.3",
    "@nestjs/common": "^10.0.2",
    "@nestjs/core": "^10.0.2",
    "@nestjs/platform-express": "^10.0.2",
    "@nestjs/swagger": "^8.1.0",
    "@ngrx/operators": "^19.0.0",
    "@ngrx/signals": "^19.0.0-rc.0",
    "app-root-path": "^3.1.0",
    "axios": "^1.7.9",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.1",
    "copy-webpack-plugin": "^12.0.2",
    "depcheck": "^1.4.7",
    "express": "~4.18.2",
    "firebase": "^11.0.2",
    "firebase-admin": "^13.0.1",
    "firebase-functions": "^6.2.0",
    "firebaseui": "^6.1.0",
    "firebaseui-angular": "^6.3.0",
    "fs-extra": "^11.2.0",
    "nanoid": "^3.3.4",
    "ngx-device-detector": "^9.0.0",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.0",
    "source-map-support": "^0.5.21",
    "spotify-uri": "^4.1.0",
    "stripe": "^17.4.0",
    "zone.js": "~0.15.0"
@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@pwejar
Copy link

pwejar commented Jan 4, 2025

here is example of code that cause this issue. ssr standalone angular 19.`import {
Component,
effect,
inject,
Input,
OnInit,
signal,
} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {
IonContent,
IonHeader,
IonTitle,
IonToolbar,
IonInfiniteScroll,
InfiniteScrollCustomEvent,
IonInfiniteScrollContent,
} from '@ionic/angular/standalone';
import { FirebaseService } from 'src/app/services/firebase.service';
import { Folder, Item } from 'src/app/app.interface';
import { ItemThumbnailComponent } from 'src/app/components/item-thumbnail/item-thumbnail.component';
import { FolderComponent } from 'src/app/components/folder/folder.component';
import {
collection,
getDocs,
limit,
query,
where,
} from '@angular/fire/firestore';

@component({
selector: 'app-items',
templateUrl: './items.page.html',
styleUrls: ['./items.page.scss'],
standalone: true,
imports: [
IonContent,
IonHeader,
IonTitle,
IonToolbar,
CommonModule,
FormsModule,
ItemThumbnailComponent,
FolderComponent,
IonInfiniteScroll,
IonInfiniteScrollContent,
],
})
export class ItemsPage implements OnInit {
firebase: FirebaseService = inject(FirebaseService);
count = signal(34);
searchTerm!: string;
searchedResults!: Item[];
displayFolders!: Folder[];
displayItems!: Item[];
itemsLoading!: boolean;
constructor() {
effect(() => {
if (this.firebase.store()) {
this.displayFolders = this.firebase.store()!.folders;
this.getItems();
}
});
}

ngOnInit() {}
openFolder(folder: Folder, index: number) {
console.log(folder);
}
async getItems() {
this.itemsLoading = true;
const collectionRef = collection(this.firebase.firestore, 'items');
const collectionQuery = query(
collectionRef,
where('public', '==', true),
where('storeID', '==', this.firebase.store()!.id),
limit(this.count())
);
const collectionSnapShot = await getDocs(collectionQuery);
const itemsHolder = collectionSnapShot.docs.map((doc) => ({
id: doc.id,
...(doc.data() as Item),
}));
// console.log(itemsHolder)
this.firebase.displayItems.update((oldItems: Item[]) => {
const newItems = itemsHolder.filter(
(newItem) => !oldItems.some((oldItem) => oldItem.id === newItem.id)
);
return [...oldItems, ...newItems];
});
this.itemsLoading = false;
}
onIonInfinite(event: InfiniteScrollCustomEvent) {
this.count.update((oldCount) => oldCount + 30);
setTimeout(() => {
event.target.complete();
}, 500);
}
}
`

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

No branches or pull requests

3 participants