Почему выводится старое значение state?
Because this.props and this.state may be updated asynchronously, you should not rely on their values for calculating the next state.Документация
Вот так правильно:this.setState(
  (state) => ({test: !state.test}),
  () => console.log(this.state.test)
);
Because this.props and this.state may be updated asynchronously, you should not rely on their values for calculating the next state.Документация
Вот так правильно:this.setState(
  (state) => ({test: !state.test}),
  () => console.log(this.state.test)
);