react-with-stable
react-with-stable copied to clipboard
How to use withStable in combination with forwardRef?
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.