I have an app with multiple screens. One screen has a canvas on it and I need to switch between the canvas screen and other screens.
I have discovered that if you do this several times then it seems to eat up the phones memory and eventually the app will start running extremely slowly.
I am assuming that each time you navigate to the canvas screen it opens up a new one in the phones memory. Is there any way to close the canvas screen ?
I may be barking up the wrong tree but I cannot think of any other reason why the app suddenly starts running slowly. It usually happens after opening the canvas screen about 8 times.
Any ideas what I can do about this ?
I think I have found a solution.
Whenever you navigate to another screen, remove the canvas like this…
I am assuming that the screen will remain in memory though so would it result in a similar problem if you switch screens enough times ?
Are you using a Stack Navigator, Folder Navigator or Tab Navigator?
I am not using navigators, just using standard button click events to switch screens.
Try the Tab navigator (top or bottom)… you might like it
Navigators would work as it looks like they don’t actually open new screens each time, but I don’t really want to use a navigator in this case.
It is a puzzle game and I want to be able to open the game screen via buttons that set various parameters for each level of the game. I also want to go from the game screen to a result screen without it appearing like a completely different screen, so navigators are not really useful in this case.
Maybe if there was some sort of hidden navigator option that could be triggered via a button. That would be useful.
The “remove canvas” option seems to work, although I still think screens are constantly being opened each time you use a button to navigate to another screen. There really should be an option to close a screen completely (like I think there was in thunkable classic)
Bingo, you just described the Tab navigator. You can hide its generic buttons and design your own UI for that.
This is what you are avoiding with the Tab navigator.
Ping me on Discord if you would like to chat about this.
I had a quick play around but couldn’t find a way to hide the navigation bar completely, which is what I would need to do.
Unless I use a bottom navigator and then then set “Tab bar visible” to false in each screen, but then I cannot see a way to trigger the navigator via a standard button.
Right, after a couple of experiments I think I have sorted it…
If I use a bottom navigator and drop all the screens inside it, then set “Tab bar visible” to false in each screen, I can then just use a standard button and the navigate to screen function.
This seems to work and stops each screen from reopening every time.
Thanks for your help @Deluxe