browniefed / react-native-ticker

React Native Number Ticker
https://www.npmjs.com/package/react-native-ticker
460 stars 46 forks source link

Bug Fix for iPhone X #11

Closed gilberger closed 5 years ago

gilberger commented 5 years ago

Hey!

Been experiencing the same issue as described in https://github.com/browniefed/react-native-ticker/issues/10

this change should solve this issue.

Cheers.

browniefed commented 5 years ago

Hey thanks for the contribution and figuring out the issue. If you reference previous state we need to use an updater function with setState

Can you switch it over to be the below code and I'll merge it.

this.setState(state => {
    if (state.measured) {
        return null;
    }
    return {
        measured: true,
        height: e.nativeEvent.layout.height,
    };
});
gilberger commented 5 years ago

Sure. committed again with the changes.

Thanks for sharing this code!