在下面的代碼中是否可以有條件地渲染Where語句(基于現有的變量)?useEffect(() => { const getProducts = projectFirestore.collection(collection) .where("color", "==", `${urlColor}`) .where("size", "==", `${urlSize}`) .onSnapshot((snap) => { ... }) return () => getProducts(); },[collection]) return { docs };}我從 URL 參數中提取“urlColor”和“urlSize”,但它們僅在用戶選擇該選項時才存在。我想要這樣的功能if (urlColor && .where("size", "==", `${urlSize}`))非常感謝任何幫助,馬特
如何在 Firestore 查詢中有條件地呈現“Where”語句?
拉風的咖菲貓
2023-08-10 14:36:56