title: I got an error when i try to update data from firestore "FirebaseError: Function CollectionReference.doc()"
body: <p>I'm creating a small react native app, when i add some code to update some data from firebase it shows me this error on console:
  "FirebaseError: Function CollectionReference.doc() requires its first argument to be of type non-empty string, but it was: undefined"</p>
  
  <p>Code of my action:</p>
  
  <pre><code>const updateChat =(newChat)=&gt;{ 
  
    return (dispatch)=&gt;{    
      console.log("trying to update: ", newChat);
      console.log("trying to update and getting the id: ", newChat.id);
      firestore.firestore().collection("chat").doc(newChat.id)
       .update(
         {
           msg: newChat,
         }
        )
       .then(() =&gt;{ 
         dispatch({
           type:'UPDATE_CHAT',  
         })  
        })
        .catch(function(error) {
          console.error("Error updating document: ", error);
      })
   }}
  </code></pre>
  
  <p>Code of my component:</p>
  
  <pre><code>class SettingsScreen extends React.Component {
    static navigationOptions = {
      title: 'Chat Screen',
    };
     state = {
         id: "",
         chat_input: "",
         updated: false,
     }
  
     onNewChat = () =&gt; {
  
         this.props.addChat(
             this.state.chat_input
         )
         this.setState({
             chat_input: ""
         });
         Keyboard.dismiss();
     }
  
      handleUpdate  = (id, chat_input) =&gt; {
          this.setState(
              {
                  id:id,
                  chat_input: chat_input,
                  updated: true,
              }
          )
      }
      saveUpdate=()=&gt;{
          this.props.updateChat(this.state.chat_input)
          this.setState({
              chat_input: "",
              id: "",
         })  
       }
  
     renderItem = ( {item} ) =&gt; {
         return (
             &lt;View style={styles.row}&gt;
                 &lt;Text style={styles.message} &gt;{item.msg}&lt;/Text&gt;
                 &lt;TouchableOpacity
                      style={styles.button}
                      onPress={ () =&gt; {this.props.deleteChat(item.id)} }
                  &gt;
                    &lt;Image
                      source={require('../assets/images/trash2.png')}
                      fadeDuration={0}
                      style={{width: 30, height: 30}}
                    /&gt;
                  &lt;/TouchableOpacity&gt;
                  &lt;TouchableOpacity
                      style={styles.buttonEdit}
                      onPress={ () =&gt; { this.handleUpdate(item.id, item.msg} }
                  &gt;
                    &lt;Image
                      source={require('../assets/images/edit.png')}
                      fadeDuration={0}
                      style={{width: 30, height: 30}}
                    /&gt;
                  &lt;/TouchableOpacity&gt;
             &lt;/View&gt;
         );
     }
  
    render() {
      const { thread } = this.props || []
  
         if (!thread) {
             return (
                  &lt;View style={styles.container}&gt;
                      &lt;Text&gt;Loading...&lt;/Text&gt;
                  &lt;/View&gt;
             )
         }
      return ( 
         &lt;View style={styles.container}&gt;
                 &lt;FlatList
                     data={thread}
                     renderItem={this.renderItem}
                     inverted
                     keyExtractor={(item, index) =&gt; index.toString()}  
                 /&gt;
                 &lt;KeyboardAvoidingView behavior="padding"&gt;
                     &lt;View style={styles.footer}&gt;
                         &lt;TextInput
                             value={this.state.chat_input}
                             onChangeText={text =&gt; this.setState({ chat_input: text })}
                             style={styles.input}
                             underlineColorAndroid="transparent"
                             placeholder="Type something nice"
                         /&gt;
                         &lt;TouchableOpacity onPress={
                              this.state.updated
                                  ? this.saveUpdate()
                                  : this.onNewChat.bind(this)
                              }
                          &gt;
                             &lt;Text style={styles.send}&gt;Send&lt;/Text&gt;
                         &lt;/TouchableOpacity&gt;
                     &lt;/View&gt;
                 &lt;/KeyboardAvoidingView&gt;
             &lt;/View&gt;
      );
    }
  }
  const mapStateToProps = (state) =&gt; {
   return {
     thread: state.firestore.ordered.chat 
   }
  }
  
  export default compose(
     connect(mapStateToProps, {addChat, deleteChat, updateChat}),
     firestoreConnect([
         { collection: 'chat'},
     ]))(SettingsScreen);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/oJTVA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oJTVA.png" alt="I got this error on console"></a></p>