NativeBase
NativeBase copied to clipboard
Issues with ForwardedRef types used on Native Base components.
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
- Create a component that is wrapped in forwardRef
- Add the correct type hint to the ref argument of the component in
ForwardedRef<RefType> - TS linter errors due to Native Base expecting a prop type of
MutableRef<any> | undefined, whilstForwardedRef<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>
Hi @imaspen, Thank you for reporting this. We will look into it.
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"