Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions on ActionSheetProvider ref are all undefined #252

Open
mikeislearning opened this issue Dec 14, 2021 · 1 comment
Open

Functions on ActionSheetProvider ref are all undefined #252

mikeislearning opened this issue Dec 14, 2021 · 1 comment

Comments

@mikeislearning
Copy link

mikeislearning commented Dec 14, 2021

I created an exportable ref with
export const actionSheetRef = React.createRef<ActionSheetProvider>(), and applied it to the ActionSheetProvider.
When I then try to access it, using either actionSheetRef.current or actionSheetRef.current._actionSheetRef.current, all the typed functions don't seem to be accessible, even though the typescript definition file shows this:

export default class ActionSheet extends React.Component<Props, State> {
    static defaultProps: {
        useNativeDriver: boolean;
    };
    _actionSheetHeight: number;
    state: State;
    _deferNextShow?: () => void;
    _setActionSheetHeight: ({ nativeEvent }: any) => any;
    render(): JSX.Element;
    _renderSheet(): JSX.Element | null;
    showActionSheetWithOptions: (options: ActionSheetOptions, onSelect: (i: number) => void) => void;
    _selectCancelButton: () => boolean;
    _onSelect: (index: number) => boolean;
    _animateOut: () => boolean;
}

I'd like to programatically close the action sheet using either _animateOut or _selectedCancelButton, but accessing that key returns undefined.

Has anyone had any luck getting ref to work properly?

@bradbyte
Copy link
Collaborator

I haven't tested this, but we probably need to tap into the imperative ref hook that would expose those internal methods to a parent.

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

No branches or pull requests

2 participants