Skip to content

fix(button): type touchableRef as a ref to the touchable's instance - #5256

Open
isaacrowntree wants to merge 1 commit into
callstack:5.0from
isaacrowntree:fix/button-touchable-ref-type
Open

isaacrowntree wants to merge 1 commit into
callstack:5.0from
isaacrowntree:fix/button-touchable-ref-type

Conversation

@isaacrowntree

@isaacrowntree isaacrowntree commented Nov 20, 2026 •

Copy link
Copy Markdown

Motivation

On React Native 0.87+, View in RN's types is the component, not its instance (#5166), so touchableRef?: React.RefObject<View> rejects useRef<ViewInstance>(null), and callback refs never fit RefObject. This backports #5167's typing, React.Ref<React.ComponentRef<typeof View>>, to 5.x for Button. Before 0.87 that type is the View instance, so existing code still compiles.

Related issue

Backport of the Button part of #5167, for #5166.

Screenshots / Videos

Types only, so nothing changes on screen.

Test plan

  • New test: a callback touchableRef gets the instance on mount and null on unmount. It doesn't compile before this change.
  • yarn typescript and yarn test pass.
  • Type-checked in an RN 0.88 app: <Button touchableRef={useRef<ViewInstance>(null)} /> compiles without a cast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Found potential problems with the pull request:

  • Screenshot or video evidence is missing. Make sure to include one if it affects the UI.

@Doberjohn Doberjohn added this to the 5.15.6 milestone Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants