Use useImperativeHandle when you need to customize the methods or properties that are exposed to parent components through a ref, allowing parent components to interact with child components imperatively.