Coding task · JavaScript and React course · Module 5: useEffect and Custom Hooks
Practice: useArray and usePrevious
Implement two custom hooks: useArray (array management with push, removeByIndex, update, clear, filter operations) and usePrevious (remembering the previous value using useRef + useEffect). useArray: useState with array-modifying functions. usePrevious: useRef stores the value, useEffect updates it after render.
Task
Create a custom hook useArray(initialArray) returning { array, set, push, removeByIndex, update, clear, filter } and usePrevious(value) returning the previous value. The hooks should work with the crew management component on the page.