Skip to content

Resolved multiple warnings about changing state during render#453

Merged
valadas merged 1 commit intoDNNCommunity:developmentfrom
valadas:request-animation-frame-fix
Feb 14, 2022
Merged

Resolved multiple warnings about changing state during render#453
valadas merged 1 commit intoDNNCommunity:developmentfrom
valadas:request-animation-frame-fix

Conversation

@valadas
Copy link
Copy Markdown
Member

@valadas valadas commented Feb 14, 2022

A warning shows whenever a state that triggers a re-render happens as it is usually something that should be done before rendering and an extra render can be avoided by moving it to another lifecycle event. However in some cases it does make sense to re-render on purpose. The way to avoid the warning is to wrap the method in a requestAnimationFrame promise so that the state changes when we are sure the initial rendering is totally complete. It does not change much as it still re-renders but it kinda declares that it was on purpose and we know what we are doing. This way the warning goes away.

A warning shows whenever a state that triggers a re-render happens as it is usually something that should be done before rendering and an extra render can be avoided by moving it to another lifecycle event. However in some cases it does make sense to re-render on purpose. The way to avoid the warning is to wrap the method in a requestAnimationFrame promise so that the state changes when we are sure the initial rendering is totally complete. It does not change much as it still re-renders but it kinda declares that it was on purpose and we know what we are doing. This way the warning goes away.
@valadas valadas added the enhancement New feature or request label Feb 14, 2022
@valadas valadas added this to the 0.14.0 milestone Feb 14, 2022
@valadas valadas merged commit f3f6fb4 into DNNCommunity:development Feb 14, 2022
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

Successfully merging this pull request may close these issues.

1 participant