Loading homepage
Build a React hook that manages a JavaScript Set with convenient immutable methods. State updates must trigger React renders, preserve insertion order, and compose correctly when batched.
JavaScript and TypeScript use the same contract. Tests render real React components and cover state updates and lifecycle behavior.
Input: useSet(["a", "a", "b"]) Output: set contains "a", "b" in that order.
Input: add("c"); remove("a"); toggle("b") Output: set contains only "c".
Input: clear(); reset() Output: Restores a fresh Set with the mount-time items.
Examples describe state after the corresponding React render or update.