react-native-responsive-screen icon indicating copy to clipboard operation
react-native-responsive-screen copied to clipboard

[Solved] Issue when using listenOrientationChange in hooks

Open hoanglam10499 opened this issue 5 years ago • 6 comments

Solved:

const [ state, setstate ] = React.useState(null); React.useEffect(() => { listenOrientationChange(setstate); return () => { removeOrientationListener(); };}, []);

And Package:

if (that.setState == null) { that(screenWidth < screenHeight ? 'portrait' : 'landscape'); } else { that.setState({ orientation: screenWidth < screenHeight ? 'portrait' : 'landscape' });}

Hope it helps everyone

hoanglam10499 avatar Mar 13 '20 15:03 hoanglam10499

Thank you bro! Working perfectly. Can you do a PR?

EzeMortal avatar Mar 19 '20 23:03 EzeMortal

@EzeMortal yes i did it

hoanglam10499 avatar Mar 21 '20 07:03 hoanglam10499

Can this get merged plz, it is really useful. #70

Marzdor avatar Mar 31 '20 01:03 Marzdor

Solved:

const [ state, setstate ] = React.useState(null); React.useEffect(() => { listenOrientationChange(setstate); return () => { removeOrientationListener(); };}, []);

And Package:

if (that.setState == null) { that(screenWidth < screenHeight ? 'portrait' : 'landscape'); } else { that.setState({ orientation: screenWidth < screenHeight ? 'portrait' : 'landscape' });}

Hope it helps everyone

Thanks a lot, It helped.

anisharya16 avatar Apr 25 '20 08:04 anisharya16

@anisharya16 I forked it and added the change.

https://github.com/Marzdor/react-native-responsive-screen I plan to just use the fork until he merges the change

Marzdor avatar Apr 25 '20 21:04 Marzdor

will this one be merged in? it's been months.

sammysium avatar Dec 23 '20 13:12 sammysium