Reputation: 5
I have an object in my react code as below.
const [inputs, setInputs] = useState({
groupName: '',
groupDescription: '',
priv: []
});
After setInputs to above state, I execute the below function.
const addDataToFb = () => {
console.log(inputs)
firebase.firestore().collection('userGroups').add(inputs)
.then(() => {
alert('Group successfully created')
resetButtonHandler();
})
.catch((err) => {
alert(err)
})
}
The console has logged below details. Refer this image.
Upvotes: 0
Views: 75
Reputation: 489
You can't submit undefined
values to Firestore, as displayed in your image, as Firestore throws an error when you submit them.
You can turn this behaviour off by adding the following property when initialising Firestore:
{ignoreUndefinedProperties: true}
Upvotes: 1