Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/UIMenuView.ios.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -8,23 +8,27 @@ type NativeProps = Omit<
"ref"
>;

type NativeRef = React.ComponentRef<typeof UIMenuNativeComponent>;

const show = () => {
if (__DEV__) {
console.warn(
"MenuView: show() is only supported on Android and does nothing on iOS.",
);
}
};

const MenuComponent = forwardRef<MenuComponentRef, NativeProps>(
(props, ref) => {
const nativeRef = useRef<NativeRef>(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 <UIMenuNativeComponent {...props} />;
return <UIMenuNativeComponent {...props} ref={nativeRef} />;
},
);

Expand Down
Loading