react-native-responsive-screen
react-native-responsive-screen copied to clipboard
Fix listener in hooks
Solved Issues #69. Please merge
Solved Issues #69. Please merge
I think using a callback for the listenToOrientationChange
would be a better choice.
And you seem to be re-writing most of the file.
I guess it's your formatter.
so consider something like.
`
if (typeof callback === 'function' ){
const orientation = screenWidth < screenHeight ? 'portrait' : 'landscape';
callback(orientation);
};`
Lesser code and solves the problem for functional and class based components.
Try refactoring your code, and make changes only to the lines that concerns your PR.
@Cmion I didn't change all the files, it was a change of the format code. You can see the "File Changed".
I'm not a maintainer, contributor or anything. But It seems like your recent commit made those changes.
I also looks like the library needs some maintenance too
@Cmion It was a change of the format code ...
Some quick, hopefully constructive, feedback on this PR:
- to keep the PR clean, get rid of the commented out code. We have version control 😃
- as @Cmion suggests in his post, consider using
===
for the comparison operator - I'd like to see this more explicit in terms of what parameter it is getting/using. Maybe have 2 parameters:
const listenOrientationChange = ({classComponentThis = null, setStateHook = null}) => { // . . . if (classComponentThis) { classComponentThis.setState(...); } else if (setStateHook) { setStateHook(...); } }
Thank you for your efforts on this! Really, really appreciated.