title: TypeError: this.state.regrex.map is not a function
body: <p>I am using <code>react</code> with custom <code>API</code> and getting error <strong>TypeError: this.state.regrex.map is not a function</strong>. when i fetching data from API then the getting error <strong>TypeError: this.state.regrex.map is not a function</strong> </p>
  
  <pre><code> import React, { Component } from 'react'
      import ApiService from "../../service/ApiService";
      import Table from '@material-ui/core/Table';
      import TableBody from '@material-ui/core/TableBody';
      import TableCell from '@material-ui/core/TableCell';
      import TableHead from '@material-ui/core/TableHead';
      import TableRow from '@material-ui/core/TableRow';
      import Button from '@material-ui/core/Button';
      import CreateIcon from '@material-ui/icons/Create';
      import DeleteIcon from '@material-ui/icons/Delete';
      import Typography from '@material-ui/core/Typography';
  
      class ListUserComponent extends Component&lt;any,any&gt;{
  
          constructor(props: any){
              super(props)
              this.state = {
                  users: [],
                  regrex: [],
                  category: null,
                  message: null
              }
              this.deleteUser = this.deleteUser.bind(this);
              this.editUser = this.editUser.bind(this);
              this.addUser = this.addUser.bind(this);
  
              this.fetchCategoryList = this.fetchCategoryList.bind(this); 
  
              this.reloadUserList = this.reloadUserList.bind(this);
          }
  
          componentDidMount() {
              this.reloadUserList();
  
              this.fetchCategoryList(this.requesDATA());
              console.log('govind'+this.fetchCategoryList(this.requesDATA()));
          }
  
      requesDATA()
      {
          let data1= {"scSymbol":"ACC"};
          return data1;
      }
  
          fetchCategoryList(category: any) {
              ApiService.fetchCategory(category)
                  .then((res) =&gt; {
                      this.setState({regrex: res.data})
                  });
          }
  
          reloadUserList() {
              ApiService.fetchUsers()
                  .then((res) =&gt; {
                      this.setState({users: res.data})
                  });
          }
  
          deleteUser(userId: any) {
              ApiService.deleteUser(userId)
                 .then(res =&gt; {
                     this.setState({message : 'User deleted successfully.'});
                     this.setState({users: this.state.users.filter((user: { id: any; }) =&gt; user.id !== userId)});
                 })
          }
  
          editUser(id: any) {
              window.localStorage.setItem("userId", id);
              this.props.history.push('/edit-user');
          }
  
          addUser() {
              window.localStorage.removeItem("userId");
              this.props.history.push('/add-user');
          }
  
          render() {
              return (
                  &lt;div&gt;
                      &lt;Typography variant="h4" style={style}&gt;User Details&lt;/Typography&gt;
                      &lt;Button variant="contained" color="primary" onClick={() =&gt; this.addUser()}&gt;
                          Add User
                      &lt;/Button&gt;
  
                      &lt;Table&gt;
                          &lt;TableHead&gt;
                              &lt;TableRow&gt;
                                  &lt;TableCell&gt;Id&lt;/TableCell&gt;
                                  &lt;TableCell&gt;category&lt;/TableCell&gt;
                                  &lt;TableCell align="right"&gt;image&lt;/TableCell&gt;
                              &lt;/TableRow&gt;
                          &lt;/TableHead&gt;
  
  
                          &lt;TableBody&gt;
                              {this.state.regrex &amp;&amp; this.state.regrex.map((row: any) =&gt; (
                                  &lt;TableRow&gt;
                                      &lt;TableCell component="th" scope="row"&gt;
                                          {row.categoryId}
                                      &lt;/TableCell&gt;
                                      &lt;TableCell align="right"&gt;{row.category}&lt;/TableCell&gt;
                                      &lt;TableCell align="right"&gt;{row.image}&lt;/TableCell&gt;
                                  &lt;/TableRow&gt;
                              ))}
                          &lt;/TableBody&gt;
  
                      &lt;/Table&gt;
  
                  &lt;/div&gt;
              );
          }
  
      }
  
      const style ={
          display: 'flex',
          justifyContent: 'center'
      }
  
      export default ListUserComponent;
  </code></pre>