Orientation listeners don't work in functional components
See original GitHub issueI was writing a functional component and I just don’t know how to subscribe to the orientation changes. Since the method listenOrientationChange accepts a class instance and use the method useState from class components.
I guess that extending the listener to functional components would be great 😉
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:6
Top Results From Across the Web
React Native: Different styles applied on orientation change
I've made some functions that return the styles object and are called on every component render's function, so I am able to apply...
Read more >A Comprehensive Guide to Working With Functional ...
The direction React is heading towards is a functional style of coding that makes ... So what are hooks and functional components all...
Read more >Understanding common frustrations with React Hooks
React Hooks can be frustrating despite their popularity and widespread use. Learn about some of the drawbacks to using React Hooks.
Read more >Using functional components as screens | React Native ...
Both class components and functional components can be used as screens. There is no performance difference between the two. Deciding which type component...
Read more >42-react-native-orientation-locker - NPM Package Overview
When UI orientation changed, callback function will be called. But if lockToXXX is called , callback function will be not called untill ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

See my pull request: PR https://github.com/marudy/react-native-responsive-screen/pull/83
It has updated docs and a hook example and everything. And the change to RNRS itself is pretty small. And adds a new feature 😃
maybe we can change some code like :
const Orientation = () => { const [dimensions, setDimensions] = useState({ window, screen });
}