The preceding example showed you how to initialize the state of a container component by making an API call in the componentDidMount() life cycle method. However, the only populated part of the component state was the users collection. You might want to populate other pieces of state that don't come from API endpoints.
For example, the error and loading state messages have default values set when the state is initialized. This is great, but what if the code that is rendering UserListContainer wants to use a different loading message? You can achieve this by allowing properties to override the default state. Let's build on the UserListContainer component:
import React, { Component } from "react";
import { users } from "./api";
import UserList from "./UserList";
export default class UserListContainer extends Component {
state = {
error: null,
users: []
};
componentDidMount() {
users().then(
result ...