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

Adopt React’s element identity behavior #252

Open
brainkim opened this issue Feb 28, 2023 · 0 comments
Open

Adopt React’s element identity behavior #252

brainkim opened this issue Feb 28, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@brainkim
Copy link
Member

React has a behavior where re-rendering identical elements is equal to a no-op. A justification which I read on the internet but now can no longer find is that it makes children passed in via props not update when the child component is re-rendered. So in the following Timer Component, the children would be static as the seconds are updated.

function *Timer({children}) {
  let seconds = 0;
  setInterval(() => {
    seconds++;
    this.refresh();
  }, 1000);
  for ({children} of this) {
    yield <div>{seconds} {children}</div>; 
  }
}

This is compelling, but I need to think about edge-cases.

It would also be a slightly breaking change for anyone naughty enough to mutate and re-render Crank elements because those changes would no longer be rendered.

@brainkim brainkim added the enhancement New feature or request label Jun 29, 2023
@brainkim brainkim added this to the 0.6 milestone Jan 9, 2024
@brainkim brainkim self-assigned this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant