The Props Collection Pattern in Practice
Let's apply the props collection pattern to our expandable component!
We'll cover the following...
The Props Collection
Take a look at the props collection for the useExpanded
hook:
Press + to interact
export default function useExpanded () {const [expanded, setExpanded] = useState(false)const toggle = useCallback(() => setExpanded(prevExpanded => !prevExpanded),[])// look here 👇const togglerProps = useMemo(() => ({onClick: toggle,'aria-expanded': expanded}),[toggle, expanded])...return value}
...
Access this course and 1400+ top-rated courses and projects.