Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于setState不能及时获取最新值 #15

Closed
liuhailang opened this issue Jan 12, 2021 · 1 comment
Closed

关于setState不能及时获取最新值 #15

liuhailang opened this issue Jan 12, 2021 · 1 comment

Comments

@liuhailang
Copy link

这里的currentSlide !== this.state.currentSlide永远不会成立
const { currentSlide } = this.state;

this.setState({
  currentSlide: Math.min(Math.max(index, 0), this.len - 1),
});

// eslint-disable-next-line react/destructuring-assignment
if (currentSlide !== this.state.currentSlide) {
  this.slideToCurrent();
  onChange.call(this);
  if (callback) {
    callback.call(this);
  }
}
@akai
Copy link
Collaborator

akai commented Jan 18, 2021

Carousel 组件已经用 hooks 重构了,你说的问题已不存在

@akai akai closed this as completed Jan 18, 2021
captainstdin pushed a commit to captainstdin/ChatUI that referenced this issue May 31, 2023
Correct the improper context being used when it exceeds the limit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants