1

I am currently working on an app and I just started on the search filter but it is throwing the following error:

Function Query.where() called with invalid data. Unsupported field value: a custom U object

and this is the code to the search screen

import React, { useState } from 'react';
import { View, Text, TextInput, FlatList } from 'react-native';

import firebase from 'firebase';

export default function Search() {
  const [patients, setPatients] = useState([]);

  const fetchPatients = (searchTxt) => { 
    firebase
      .firestore()
      .collection('Patients')
      .where('doctorEmail', '==', firebase.auth().currentUser.email)
      .where('patientName', '>=', searchTxt)
      .get()
      .then((snapshot) => {
        let patients = snapshot.docs.map(doc => {
          var data = doc.data()
          var id = doc.id
          return {id,...data}
        })
        setPatients(patients)
      })
  };

  return (
    <View>
      <TextInput
        placeholder="Search..."
        style={{padding:100,marginTop:100}}
        onChange={(searchTxt) => {fetchPatients(searchTxt)
        console.log(patients)}}
      />
    </View>
  );
}

This is my database structure

enter image description here

This is the last part of a patient document

if you have any idea on how to fix this issue please let me know...Any help would be appreciated

Vibha
  • 77
  • 11

1 Answers1

1

I think the problem is in how the firebase.auth().currentUser.email & searchText is being sent to the query.

Check this post out.

Huthaifa Muayyad
  • 11,321
  • 3
  • 17
  • 49