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

[compiler] Off-by-default validation against setState directly in passive effect #30685

Merged
merged 2 commits into from
Aug 15, 2024

Commits on Aug 14, 2024

  1. [compiler] Off-by-default validation against setState directly in pas…

    …sive effect
    
    Per discussion today, adds validation against calling setState "during" passive effects. Basically, it's fine to _schedule_ setState to be called (via a timeout, listener, etc) but generally not recommended to call setState during the effect since that will trigger a cascading render.
    
    This validation is off by default, i'm putting this up for discussion and to experiment with it internally.
    
    [ghstack-poisoned]
    josephsavona committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    4ba9eb0 View commit details
    Browse the repository at this point in the history
  2. Update on "[compiler] Off-by-default validation against setState dire…

    …ctly in passive effect"
    
    
    Per discussion today, adds validation against calling setState "during" passive effects. Basically, it's fine to _schedule_ setState to be called (via a timeout, listener, etc) but generally not recommended to call setState during the effect since that will trigger a cascading render.
    
    This validation is off by default, i'm putting this up for discussion and to experiment with it internally.
    
    Rationale: https://react.dev/learn/you-might-not-need-an-effect
    
    [ghstack-poisoned]
    josephsavona committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    fa560ce View commit details
    Browse the repository at this point in the history