Problems

Effect Cleanup Order

MediumComponent Lifecycle

An effect with a dep re-runs as: cleanup(old) THEN effect(new). Input: one dep value per line (first line mounts). Print the log: effect V on each run and cleanup V (previous value) before each re-run; end with cleanup LAST for unmount.

Input: dep values, one per line. Output: the full log.

Your program reads from stdin and prints to stdout.

Example 1

Input: 1 2 3

Output: effect 1 cleanup 1 effect 2 cleanup 2 effect 3 cleanup 3

Hints

ReactLifecycleuseEffect
Effect Cleanup Order | CodeForge AI