DEV Community

Discussion on: Using React.forwardRef() and an HOC on the same component

Collapse
 
marien_db profile image
Marien den Besten • Edited

The trick is to also incorporate 'forwardRef' in the HOC.

function withHookHOC(Component) {
    return forwardRef(({...props}, ref) => {
         return <Component {...props}
                          ref={ref}/>
    });
}
Enter fullscreen mode Exit fullscreen mode