react-with-stable icon indicating copy to clipboard operation
react-with-stable copied to clipboard

How to use withStable in combination with forwardRef?

Open swayok opened this issue 2 years ago • 0 comments

Hi. I need to wrap a component into forwardRef() and want to also use withStable().

I tried to to this way:

const Button = forwardRef((props, ref) => {
    ....
})

export default withStable(['onClick'], (props: ButtonProps) => <Button {...props}/>)

But there are warning in console: Warning: Function components cannot be given refs.

So I need to place withStable inside forwardRef somehow, but I do not understand how to do this correctly.

swayok avatar Sep 01 '23 13:09 swayok