GeekyAnts / GeekyAnts/NativeBase

Issues with ForwardedRef types used on Native Base components.

Open
#5,158 2 comments 1 reaction 1 assignee Claimed by @Viraj-10 View on GitHub
bug typescript v3
Dominant language
TypeScript
Stars
20.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

### 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`
3. TS linter errors due to Native Base expecting a prop type of `MutableRef | undefined`, whilst `ForwardedRef` resolves to `((instance: RefType | null) => void) | MutableRefObject | 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`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.