In the code below is it possible to conditionally render the Where statements at all (based on a variable existing)?
useEffect(() => {
const getProducts = projectFirestore.collection(collection)
.where("color", "==", `${urlColor}`)
.where("size", "==", `${urlSize}`)
.onSnapshot((snap) => {
...
})
return () => getProducts();
},[collection])
return { docs };
}
I'm pulling in the 'urlColor' and 'urlSize' from URL parameters but they only exist if the user selects that option. I'd like functionality like
if (urlColor && .where("size", "==", `${urlSize}`))
Any help much appreciated, Matt