Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Solved] Issue when using listenOrientationChange in hooks #69

Open
hoanglam10499 opened this issue Mar 13, 2020 · 6 comments
Open

[Solved] Issue when using listenOrientationChange in hooks #69

hoanglam10499 opened this issue Mar 13, 2020 · 6 comments

Comments

@hoanglam10499
Copy link

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

@EzeMortal
Copy link

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

@hoanglam10499
Copy link
Author

@EzeMortal yes i did it

@Marzdor
Copy link

Marzdor commented Mar 31, 2020

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

@anisharya16
Copy link

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.

@Marzdor
Copy link

Marzdor commented Apr 25, 2020

@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

@sammysium
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants