question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Solved] Issue when using listenOrientationChange in hooks

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

5reactions
Marzdorcommented, 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

3reactions
hoanglam10499commented, Mar 21, 2020

@EzeMortal yes i did it

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native with typescript passing useState as props
I have responsive.tsx file and I want to take an useState hook as props that contains orientation mode for app from app.tsx. I...
Read more >
React.useEffect Hook – Common Problems and How to Fix ...
The first and probably most obvious option is to remove the dependency from the useEffect dependency array, ignore the ESLint rule, and move...
Read more >
react-native-responsive-screen-hooks: Docs & more | Openbase
section. There are 2 more methods to use if you want to support responsiveness along with orientation change. These are listenOrientationChange and ...
Read more >
Build responsive React Native views for any device ... - Medium
The goal of this article is to show a complete solution that scales RN UI to all sizes and types of screens (phones,...
Read more >
Understanding common frustrations with React Hooks
Learn about some of the drawbacks to using React Hooks. ... What problems do React Hooks solve? What was wrong with class components?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found