NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Issues with ForwardedRef types used on Native Base components.

Open imaspen opened this issue 3 years ago • 2 comments

Description

The type definition for the ref prop on at least the Button component are incorrect and don't support a forwarded ref.

CodeSandbox/Snack link

https://codesandbox.io/s/quiet-thunder-rvtxu6?file=/src/ExampleButton.tsx

Steps to reproduce

  1. Create a component that is wrapped in forwardRef
  2. Add the correct type hint to the ref argument of the component in ForwardedRef<RefType>
  3. TS linter errors due to Native Base expecting a prop type of MutableRef<any> | undefined, whilst ForwardedRef<any> resolves to ((instance: RefType | null) => void) | MutableRefObject<RefType | null> | null.

NativeBase Version

3.4.6

Platform

  • [X] Android
  • [X] CRA
  • [X] Expo
  • [X] iOS
  • [X] Next

Other Platform

All platforms

Additional Information

Typing for ref prop should be expanded to include both null and ((instance: any | null) => void), or changed to be ref?: ForwardedRef<any>

imaspen avatar Jul 14 '22 13:07 imaspen

Hi @imaspen, Thank you for reporting this. We will look into it.

Krithikj20 avatar Jul 15 '22 04:07 Krithikj20

I am facing the same problem with Modal. Hope that it can be solved soon. So that I can improve the performance on Modal.

Native-base version "native-base": "3.5.0-alpha.7"

BenFungInUK avatar Aug 10 '22 06:08 BenFungInUK