Provide a way to detect infinite component rendering recursion in development
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 251k
- Forks
- 51.4k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 53
Description
Do you want to request a feature or report a bug?
- Feature (possibly bug?)
What is the current behavior?
I've been trying out the new Context API in my project and it's awesome. However, in my haste to start using it, I managed to stumble into a situation where every time I would try and render a certain component which was making use of a few different contexts, the app would completely freeze, and the only thing that would let me get out of this error state was to forcefully kill the process via the chrome task manager.
Nothing would be logged to the console, the app would just completely freeze, and when I opened up the task manager and saw the CPU spiked up every time i would go to this component, and the only way I could stop it was to crash the tab.
I finally threw some console statements in and saw that it had just entered into an infinite loop between these providers. I managed to get the app to stop crashing, but I'm still unsure as to why exactly this was happening. I'm sure I was just using this API incorrectly somehow, but this was a very confusing problem to diagnose, and some error checking here would be incredibly useful
What is the expected behavior?
It would be very beneficial to have some sort of checks in place, similar to what happens with too many setState calls happening too closely when you call it from componentDidUpdate, for example. That way, instead of freezing everything up permanently, the app could at least crash and report some sort of information and help me realize where I'd gone wrong.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
- React
16.3.0 - Chrome
65.0.3325.181
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Aucun fichier source, test ou exemple reproductible n’est indiqué. Commencez par reproduire la Context API/provider render loop décrite pour React 16.3.0 dans Chrome 65, puis suivez le componentDidUpdate setState recursion guard existant ; c’est terminé lorsqu’un diagnostic réservé au développement arrête le gel et fournit suffisamment de contexte pour identifier la boucle.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, react
- Domaine
- frontend
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 30/100