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

How to open() or hide() panel with Redux actions #207

Open
mhb-yt opened this issue Sep 7, 2021 · 2 comments
Open

How to open() or hide() panel with Redux actions #207

mhb-yt opened this issue Sep 7, 2021 · 2 comments

Comments

@mhb-yt
Copy link

mhb-yt commented Sep 7, 2021

How can I triger open() / hide() from anywhere in my App? Ideally I would like to use Redux actions for this.

Since the prop visible is not available, I don't know how to control the open/close state using redux actions. The only solution I see is forwardRefs, but it makes the code quite complicated.

Any advice on that?

@YuryKorovko
Copy link

The same question for me as well

@keeprock
Copy link

keeprock commented Dec 30, 2021

There is no other way except using the Ref.

const panelReference = React.createRef();

When pass it to the SlidingUpPanel:

<SlidingUpPanel
            ref={panelReference}
            ...
>

Now you can access various methods (code in Typescript):

panelReference.current?.hide();
panelReference.current?.show();

https://octopitus.github.io/rn-sliding-up-panel/#methods

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

3 participants