troberts-28 / react-native-timer-picker

A simple, flexible, performant duration picker for React Native apps (Expo & Bare Workflow). Great for timers, alarms and duration inputs. Includes iOS-style haptic and audio feedback.
https://www.npmjs.com/package/react-native-timer-picker
MIT License
142 stars 19 forks source link

Changing Orientation #14

Closed ollie232 closed 1 year ago

ollie232 commented 1 year ago

When changing from portrait to landscape and vice versa " Cannot read property 'width' of undefined" error occurs.

This error stems from line 17 within \dist\components\modal\index.js

troberts-28 commented 1 year ago

Hey @ollie232, thanks for raising this. Will take a look at this and fix it!

ollie232 commented 1 year ago

Hello I manged to find a fix. However this maybe environment specific.

You can change line 39 and line 40 within node_modules/react-native-timer-picker/dist/components/Modal/index.js to the code below.

var updatedScreenWidth = dimensionsUpdate.windowPhysicalPixels.width; var updateadScreenHeight = dimensionsUpdate.windowPhysicalPixels.height;

width_error_fix

troberts-28 commented 1 year ago

That should be sorted now 🙌

I realised that that whole pattern of listening to a dimensions change and updating state was really outdated. There's now a neat useWindowDimensions() hook that receives updates to the dimensions.