class vs. component difference on closure:
-
CodeSandBox: class vs. function component compares how function components and classes "close over" values. Play with it.
- Solution: Click "Follow", then quickly change profile and observe name in alert.
- Explanation:
this.propsis mutable in class components and immutable (const) in function components.
-
CodeSandBox: fix class component issue by storing the user at the time of the click.