GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Modul 9 von 13 · Medien

Reset the state after unmount

Kostas Diakogiannis

Reset the state after unmount

Reset the state after unmount

The previous solution works well for now, but generates a specific problem.

Now that the shouldRedirect is set to true, will stay like that forever. That means if we navigate to this component again, we are going to redirect immediately and not after 5 seconds, since the value is true and this fact will trigger the Redirect component.

What you should do, is reset the shouldRedirect state's value again to back to false, immediately after the component unmounts. 

Hint: Maybe you will find componentWillUnmount lifecycle method extremely useful here.

Anleitung

Um im Kurs weiterzukommen, sende einen Versuch dieses Quiz ab. Du kannst ihn nach der letzten Frage absenden.

Zum gewählten Modul

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck