educative.io

onExpand is it a prop and what does it do to expanded?

In the Course, I see the onExpand prop and it is used in the useEffect hook but I don’t get what it does?

Hey @Yahya_Elfaqir

When the component wasn’t controlled, the onExpand prop was a user-defined function invoked after every state change. That’s not going to be relevant if the component is controlled. Why? The user handles the toggle function themselves when the component is controlled. They can choose to do anything in the callback with the already controlled state value too.

Happy learning,