title: Update multiple fields using Firebase React Native Hooks
body: <p>I want to update multiple fields from user input data using useState, but I can't seem to find any example for that.</p>
  <pre><code>const [productName, setProductName] = useState(props.route.params.productName)
  const [caption, setCaption] = useState(props.route.params.category)
  const [category, setCategory] = useState(props.route.params.caption)
  const [receiveDate, setReceiveDate] = useState(props.route.params.receiveDate)
  const [expiryDate, setExpiryDate] = useState(props.route.params.expiryDate)
  
  const updatePostData = (userId, productName, caption, category, receiveDate) =&gt; {
        firebase.firestore()
              .collection('posts')
              .doc(firebase.auth().currentUser.uid)
              .collection(&quot;userPosts&quot;)
              .doc(userId)
              .update({
                    productName,
                    caption,
                    category,
                    receiveDate
                    expiryDate
                })
              .then(() =&gt; 
                  setProductName(&quot;&quot;), setCaption(&quot;&quot;), setCategory(&quot;&quot;), 
                  setReceiveDate(&quot;&quot;), setExpiryDate(&quot;&quot;))
              .catch((error) =&gt; console.log(error)); 
  }
  
  useEffect(() =&gt; {
        setProductName(productName), 
        setCaption(caption),
        setCategory(category),
        setReceiveDate(receiveDate),
        setExpiryDate(expiryDate);
        console.log(&quot;useEffect passes the currentItem: &quot;, 
        {productName, caption, category, receiveDate, expiryDate});
      }, []);
  
  &lt;TextInput 
      placeholder=&quot;Product name&quot;
      onChangeText={(productName) =&gt; setProductName(productName)}           
  /&gt; //same for other input
  
  &lt;TouchableOpacity 
      onPress={() =&gt; updatePostData(productName, caption, category, receiveDate, expiryDate)} &gt;
      &lt;Text&gt;UPDATE&lt;/Text&gt;
  &lt;/TouchableOpacity&gt;
  </code></pre>
  <p>I get this error.</p>
  <blockquote>
  <p>FirebaseError: Function DocumentReference.update() called with invalid data. Data must be an object, but it was: undefined</p>
  </blockquote>
  <p>Do I need save all fields in one new const? Or should I convert them to object? How?</p>