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

Is it possible to create stack navigation? #94

Closed
devnomic opened this issue Apr 13, 2022 · 4 comments
Closed

Is it possible to create stack navigation? #94

devnomic opened this issue Apr 13, 2022 · 4 comments

Comments

@devnomic
Copy link

Hi i just found the lib, congrats on v2 launch! looks like a really good lib.
Seems the page transition is first class support here.

Is it possible to create stack based navigation? The goal is to have webapp but behave like native app.
It retains the previous state.

Let's say i have page A and B, and inside page A i have an input using useState.
If i go to page B, then press go back(-1) then A will lose it's state since it's unmounted.

Is it possible to have greater control over unmount?
So, instead of unmount it, just hide it, so previous page can retain it's state.

If we are using example above then it would be like:

When on page A, navigate go to page B.
then inside the Stack div element, we still have 2 div, which is A and B. but the A div is hidden.

After we arrive on page B, if we click back -1, then the Stack div will only have A div.
Is it possible?

Thanks

@willybrauner
Copy link
Member

The Stack will perform the transitions between two page instances, it will unmount the old page automatically when the pageTranstions promise is resolved. In your case, you seems to need a global state who not depend of a page instance.

@devnomic
Copy link
Author

Yeah, i thought about it, that's my last resort strategy.
I just played around with the router, hoping to use this one.

Anyway, how do i go back in history.go(-1) since i'm planning to use with memory history?

I hope the api will be simple like

setLocation(-1)

const history = useHistory();
history.back();

Thanks

@willybrauner
Copy link
Member

willybrauner commented Apr 13, 2022

As the readme mentions, this router use remix-run/history. Feel free to check its documentation.

@devnomic
Copy link
Author

Seems the sandbox is using 2.0.0 beta, that's why its not working.

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