The Scenario: "We are building a Complex Multi-Step Form Builder (similar to Typeform or Google Forms). The user can add questions, remove them, reorder them, or clear the entire form.
Because we use React.memo on our individual Question components to keep the UI snappy, we have a strict requirement: Every array manipulation must be immutable. If you accidentally mutate the existing array, the child components won't detect the change and won't re-render. Additionally, we want to avoid 'Prop Drilling' setters everywhere.
The Challenge: Implement a useArray hook that abstracts this complexity. It should return the current array and a stable set of 'Actions.' The actions (like push or update) must have stable function identities (using useCallback) so that they don't cause child components to re-render needlessly when passed as props.