首页 > 解决方案 > React Native unought typeerror: u.split is not a function

问题描述

我正在开发一个带有 react native 和 firebase 的应用程序。在搜索字段中,当我输入搜索输入时,它给了我以下错误:

错误 错误 错误 错误

这是我的代码:(一切都是进口的)

export default function Search(props) {
    const [users, setUsers] = useState([])

const fetchUsers = (search) => {
    firebase.firestore()
        .collection(users)
        .where("name", ">=", search)
        .get()
        .then((snapshot) => {
            let users = snapshot.docs.map(doc => {
                const data = doc.data();
                const id = doc.id;
                return { id, ...data }
            });
            setUsers(users);
        })
}

return (
    <View>
        <TextInput placeholder="Serach..." onChangeText={(search) => fetchUsers(search)} />

        <FlatList
            numColumns={1}
            horizontal={false}
            data={users}
            renderItem={({ item }) => (
                <TouchableOpacity
                    onPress={() => props.navigation.navigate("Profile", { uid: item.id })}>
                    <Text>{item.name}</Text>
                </TouchableOpacity>

            )}
        />
    </View>
  )
}

标签: reactjsreact-nativereduxexporeact-native-flatlist

解决方案


推荐阅读