Closed IkennaU closed 3 years ago
As the error message indicates, a function is being passed instead of an object value.
newClient
will be a function because of the line:
const newClient = setClients;
setClients
is a function because of this line here:
const [clients, setClients] = useState(initialState);
Since this is an implementation question you usually get a faster and more complete response if you reach out over Gitter
Thanks
Pls Help, each time i try to submit, it gives the error... FirebaseError: Function CollectionReference.add() requires its first argument to be of type object, but it was: a function
pls help me out
import React, { useState } from "react"; import { Link } from "react-router-dom"; import { useFirestore } from "react-redux-firebase"; import { useFirestoreConnect } from "react-redux-firebase"; import PropTypes from "prop-types";
function AddClient(props) { const firestore = useFirestore();
let initialState = { firstName: "", lastName: "", email: "", phone: "", balance: "", }; const [clients, setClients] = useState(initialState); const { firstName, lastName, email, phone, balance } = clients;
useFirestoreConnect([{ collection: "client" }]);
const onChange = (e) => setClients({ ...clients, [e.target.name]: e.target.value });
const onSubmit = (e) => { e.preventDefault(); const newClient = setClients;
};
return (
); }
AddClient.propTypes = {};
export default AddClient;