One important note, the Dimensions API is by far the most important API you have in React Native when
it comes to dynamically working with available width and height.
It's part of REAC native and does not depend on exposure or anything like that.
EXPL, however, also gives you an API you can use.
You can import something from XPO in this therefore only works and XPO app, of course, and that's
the screen orientation object.
This is an object which helps you detect screen orientation changes and also lock the screen orientation
when your app is running.
So even if you initially set No Lockyear in your app Jason file, you can still add one after you started
your app with the help of that API.
The screen orientation API has a couple of functionalities and I want to quickly walk you through them.
You can, of course, play around with them to learn more about them.
For example, you have to lock async method.
This locks the orientation in the end and you set the lock by not by now, using screen orientation
dot and then you set this to orientation lock and then, for example, to portrayed or put it down.
So a lot of configuration possibilities you have here.
And now I'm calling this in the game screen.
This means that I can freely rotate this as long as I'm configuring the game.
But as soon as the game starts, you'll see that the orientation doesn't change anymore, so that can
be useful if you need to lock this down when your app reaches a certain point.
In addition to that, screen orientation, API here also gives you a function to get your current orientation.
And async simply means that this gives you a promise.
It doesn't immediately do that.
It gives you a promise where you eventually get a result.
But the result will be there very quick, just not in the next code line immediately.
And you can also set up an orientation change listener, for example, and disorientation change listener
will do what it sounds like.
It fires a function whenever the orientation changes.
That can be useful if you have different layouts that only depend on the question whether you're in
portrait or landscape mode and not so much on the dimensions, because, of course, it's important
to keep in mind that with the code we wrote here with you is a fact where we listen to changes in the
dimensions.
We technically don't just react to orientation changes, though.
That's typically is what changes the available width and height.
There isn't really anything else that could change it.
But you're not strictly only checking for whatever orientation changed and you can't directly check
for the orientation changed and is now a portrait.
Instead, you could listen for a change and then in the function you fire checked the new available
width and kind of find out, OK, this is a lot of with we're probably in landscape now.
That is something you can guess, but you don't know because you're checking for the width and the height,
not for the orientation.
Now, typically, it's the width and height that matters to you, though you might not be interested,
whether you're in landscape mode and have a lot of width or whatever, the app is running on an iPad
and therefore has more width than on a phone.
You just might be interested in the question, how much with do I have?
And then render your layout based on that, no matter if that's the case because you're in the landscape
phone or a portrait mode iPad.
So therefore the Dimensions API is the important API.
But I didn't want to hide the screen orientation API exposes from you, especially because it can also
be used for locking and unlocking, of course, the orientation at runtime, which can be useful at
times.