How do I make something happen when a screen is closed?

Hey,

I’m trying to make a component do something, but when a screen is closed…
More specifically, I’m working with canvas blocks (make a block move when a screen is closed).

How do I go about this?

Thank you for your time,
Hobi

1 Like

What kind of navigation are you using between screens?

Well, if someone decides to switch screens using the top menu, this should come into play.

So you’re using a Top Tab navigator? I don’t see any way to do that with a navigator. You can use the Screen Open block but there isn’t a Screen Closed event block.

1 Like

Use an app variable (for example, activeScreen) to store the name of the active screen.

Update the variable activeScreen with the screen open event. For example, activeScreen=screen3

In the screen open event check if the activeScreen is equal the screen name you want. This means that the previous screen is the screen you want and then do the code you want to do and change the variable to the new screen.

This way, you will be executing codes on close of screen (with a twist).

3 Likes