Repository navigation
Firebase API called outside injection context #3605
Description
Activity
This issue does not seem to follow the issue template. Make sure you provide all the required information.
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);
}
}
`Reacted by unimodern, Alex Lykesas, GranToffino and Ethan Sarif-Kattanits happening, its not blocker issue but still hapening in latest angular
@galih9 those messages are an intentional choice made by AngularFire. Angular version has nothing to do with it. They will keep happening until you wrap every AngularFire method in an injection context. (Which isn't trivial in all cases) Or you disable the logging
Reacted by Galih Riski Pratama
Getting this console warning everywhere in my app thats using firebase, even within injection contexts
here are my deps