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

Infinite rerender on React 19 #139

Open
rklos opened this issue Jan 13, 2025 · 0 comments
Open

Infinite rerender on React 19 #139

rklos opened this issue Jan 13, 2025 · 0 comments

Comments

@rklos
Copy link

rklos commented Jan 13, 2025

Hi,
something has changed in the latest React release, because the component started to rerender repeatedly.
CleanShot 2025-01-13 at 09 48 26

The problem is line 53 in LinesEllipsis component:
https://github.com/xiaody/react-lines-ellipsis/blob/master/src/index.jsx#L53

componentDidUpdate (prevProps) {
  if (prevProps.winWidth !== this.props.winWidth) {
    this.copyStyleToCanvas()
  }
  if (this.props !== prevProps) {
    this.reflow(this.props)
  }
}

if I change the comparison of the props to something like this:

if (JSON.stringify(this.props) !== JSON.stringify(prevProps)) {
  this.reflow(this.props)
}

the problem is solved.

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

1 participant