0

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.

1
  • I got an answer. This error happens becouse of the undefined values in my object. So i put empty string to priv.privDesc. Now its working well. Commented Jul 13, 2020 at 9:23

1 Answer 1

1

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}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.