Q:

Why would this.setState not update the state object?

I am running a simple method in a React component. After computing the values I wish to set them to the state object and rerender the component.
Here is the relevant code: 
`class ManageAuthors extends Component {
  state = {authors: [], allAuthors: []};

  authorLists = allPotentialAuthors => {
    const allAuthors = allPotentialAuthors.map(mem => ({...mem, isCurrent: true});
    const authors = this.props.authors.filter({_some other filter code_});
    this.setState({authors, allAuthors});
};

  render() {
    const {authors, allAuthors} = this.state;
    console.log('state:', authors, allAuthors);
    return (
      <Query query={query}>
        {({loading, data}) => {
          if (!loading && data) {
            this.authorLists(data.authors)
          }
          return (_stuff to return_);
        }}
      </Query>
    );
  };
};`

The Query fires correctly and returns data and that data is sent to the authorLists method. Each of the const variables computes the correct values. But when the this.setState method should be called, nothing actually updates. It's like the this.setState method is not even firing. Is there something that would prevent the this.setState method from working/updating the local state object?

A:

setState does not always update the state right away. If you need access to that variable right away you can pass a function setState and play with that variable there. 
For example: 
this.setState({authors, allAuthors}, () => {
   //do something with authors or allAuthors or both
   console.log(authors); console.log(allAuthors); //log it to see if you get desired result
  }
);

React Documentation explains this pitfall: 

setState() does not always immediately update the component. It may
  batch or defer the update until later. This makes reading this.state
  right after calling setState() a potential pitfall. Instead, use
  componentDidUpdate or a setState callback (setState(updater,
  callback)), either of which are guaranteed to fire after the update
  has been applied.

Can read more about this here. Or search "setState" on React's documentation site.

