From b39ebfcbd2e3fa4b8fdae1b4565864a0a9d78c2e Mon Sep 17 00:00:00 2001 From: Jesse Katsumata Date: Sun, 29 Nov 2026 14:07:01 +0900 Subject: [PATCH] fix(ios): keep the native instance on the MenuView ref #1265 made the iOS ref `{ show }` only, so measure(), measureInWindow(), measureLayout(), setNativeProps() and findNodeHandle() on it, which worked up to 2.3.3, throw since 2.3.4. Attach show() to the native instance and expose that instance again. Co-Authored-By: Claude Opus 5.5 --- src/UIMenuView.ios.tsx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/UIMenuView.ios.tsx b/src/UIMenuView.ios.tsx index e5b69411..58550976 100644 --- a/src/UIMenuView.ios.tsx +++ b/src/UIMenuView.ios.tsx @@ -1,5 +1,5 @@ import type * as React from "react"; -import { forwardRef, useImperativeHandle } from "react"; +import { forwardRef, useImperativeHandle, useRef } from "react"; import UIMenuNativeComponent from "./NativeModuleSpecs/UIMenuNativeComponent"; import type { MenuComponentRef } from "./types"; @@ -8,23 +8,27 @@ type NativeProps = Omit< "ref" >; +type NativeRef = React.ComponentRef; + +const show = () => { + if (__DEV__) { + console.warn( + "MenuView: show() is only supported on Android and does nothing on iOS.", + ); + } +}; + const MenuComponent = forwardRef( (props, ref) => { + const nativeRef = useRef(null); + useImperativeHandle( ref, - () => ({ - show: () => { - if (__DEV__) { - console.warn( - "MenuView: show() is only supported on Android and does nothing on iOS.", - ); - } - }, - }), + () => Object.assign(nativeRef.current as NativeRef, { show }), [], ); - return ; + return ; }, );