React Error : Cannot read property ‘map’ of undefined


I am working on a react program which uses axios to get data from a rest api, but when I run the code it gives an error 'Cannot read property 'map' of undefined' on the browser. Please help me resolve this error.


import React from 'react';

import axios from 'axios';

export default class UserList extends React.Component {
  state = {
    persons: []

  componentDidMount() {
      .then(res => {
        const users =;
        this.setState({ users });

  render() {
    return (
        { => <li>{}</li>)}

Read more here:

Content Attribution

This content was originally published by hemanth h at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: