Hello there's something I really do not understand because it does not make any sense at all, I have 2 pieces of code that are EXACTLY the same only difference is the variables I use to find the collections and one does persist even after refreshing and the other one doesn't here are the pieces of code:
Students list one:
const [estudiantes, setEstudiantes] = useState([]);
const estudiantesRef = db.collection("usuarios").doc(user.uid).collection("estudiantes")
useEffect(() => {
estudiantesRef.onSnapshot(snapshot => {
const tempData = [];
snapshot.forEach((doc) => {
const data = doc.data();
tempData.push(data);
});
setEstudiantes(tempData);
})
}, []);
console.log(user.uid)
console.log(estudiantes)
Books list one:
const [productos, setProductos] = useState([]);
const productosRef = db.collection('libros');
useEffect(() => {
productosRef
.orderBy('grado')
.onSnapshot( snapshot => {
const tempData = [];
snapshot.forEach((doc) => {
const data = doc.data();
tempData.push(data);
});
setProductos(tempData);
})
}, []);
Update: The user.uid is ALWAYS present regardless of the refresh however the data stored in estudiantes disappears when I refresh and that's not good lol. Why does the data disappear ? I test it by only loading 1 collection and it doesn't disappear so why does it disappear when it goes to multiple collections and how I can fix it ?
Before Refresh
After Refresh

