Stack Overflow
Stack Overflow

Reputation: 2988

React Native - Dimensions.set() is not working?

I am new to react native and learning about handling the screen dimension for Android platform. I imported the Dimensions module and did everything right but when i call the Dimensions.set() method, nothing is happening. Here is the script:

<Button title='Set Dimension' onPress={() => {
    Dimensions.set({
        "width": 300,
        "height": 300,
        "scale": 1,
        "fontScale": 2
    });
}}/>

Can anyone tell whats wrong with my script and how to use this method? A little example will be more appreciated. Thanks !!!

Upvotes: 0

Views: 1126

Answers (1)

avani kothari
avani kothari

Reputation: 739

if you will refer the facebooks's doc for dimensions here set() method can only be called from native code and needs to be exposed with didUpdateDimensions event.

Upvotes: 2

Related Questions