Comments (4)
Hello @getsettalk
I am not working on the library, I just want to help
If you check the code for the "listenOrientationChange" function, you will see that it's designed to be only used with a class based components and it relays on the value of "this" to be passed as an argument to call setState to update the component when the orientation changes
Check the provided example here https://github.com/marudy/react-native-responsive-screen/tree/master/examples/responsive-screen-orientation-change
My suggestion to solve the issue, is that you use the new hook introduced by react native "useWindowDimensions", you can just call it inside your functional component and ignore the return (since the width and height are handled by this library), and it should automatically render your component when orientation changes, and will also do the required cleanup on unmounting
Also keep in mind that you will need to move your styles inside the component function so that the "hp" and "wp" are re-calculated when orientation changes.
Hope that helps
from react-native-responsive-screen.
from react-native-responsive-screen.
@getsettalk
As i said, I am not a developer for this library, I just wanted to provide a solution for your question
I would be happy to submit a PR to update this library, but It seems no one is maintaining it and the PR won't be submitted.
from react-native-responsive-screen.
from react-native-responsive-screen.
Related Issues (20)
- Proposed new feature GetScreenType() which returns XS,SM,M,L
- Samsung Galaxy S10 beyond 1q | 1080x2009 | 402 (dpi) font not scaled properly HOT 1
- Using heightPercentageToDP but with width keeping the same aspect ratio HOT 1
- Proposed change: Dimensions API to the useWindowDimensions hook. HOT 3
- Using the library with safe area views.
- Jest encountered an unexpected token HOT 3
- Feature Request: Able to provide viewport sizes
- TypeError: 0, _$$_REQUIRE(_dependencyMap[13(...)ive-screen").widthPercentageToDP is not a function (it is undefined)
- [Feature request] breakpointGroup to return a number instead of strings
- Font size doesn't seem to scale well when specifying as a percentage. HOT 4
- Units size expected with styled components HOT 2
- Strange results in two different emulators HOT 3
- TypeError: this.setState is not a function HOT 6
- Which lib to use? HOT 2
- TypeError: (0, _scaling.responsiveHeight) is not a function.
- will RNRS support functional components anytime soon? this.setState undefined error is still here HOT 3
- Cannot resolve symbol 'heightPercentageToDP' HOT 4
- Feature request - is there a way to have some sort of stylesheet-based listener? HOT 1
- How to use the lor() method in the function component HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-responsive-screen.