whereメソッドを使ったところ
Argument of type '"arry-contains"' is not assignable to parameter of type 'WhereFilterOp'
このようなエラーが出て
array-contains-any
に書き換えてみたり、
を参考にしてみたのですが、
解決しません、、
components/ResultPage/ResultImage.tsx import React ,{FC, useState,useEffect} from 'react'; import {useParams} from 'react-router-dom'; import firebase from '../../firebase' import {FileData} from '../../types/Types' const ImageItemList: FC =()=>{ const [data, setData] = useState<FileData[]>([]); const {keyword} = useParams(); const getData =async(searchWord: string | undefined)=>{ const db = firebase.firestore(); const fileDataRef = db.collection("fileData"); const searchedData = fileDataRef.where("keyword", "array-contains-any" , searchWord); **エラー部分** const snapShot = await searchedData.get(); const temporaryData: object[] = []; snapShot.docs.map(doc =>{ temporaryData.push(doc.data()) }) setData(temporaryData as FileData[]); } useEffect(() =>{ getData(keyword); },[]); return ( <div> </div> ) } export default ImageItemList
firebae.ts import firebase from "firebase/app"; import "firebase/firestore"; import "firebase/firebase-storage"; var firebaseConfig = { apiKey: "AIzaSyCkUItnJUMpMMVOtrrpwRSvCQf1GJ0lYuc", authDomain: "form-techpit.firebaseapp.com", databaseURL: "https://form-techpit.firebaseio.com", projectId: "form-techpit", storageBucket: "form-techpit.appspot.com", messagingSenderId: "169202913739", appId: "1:169202913739:web:4b34010c81aea9893f264e" }; // Initialize Firebase firebase.initializeApp(firebaseConfig); export default firebase;
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。