-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
ERROR TypeError: Cannot read property 'setState' of undefined, js engine: hermes #156
Comments
Hello @getsettalk 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 Hope that helps |
Thank You , but you should update is it's very helpful
…On Wed, 18 Oct 2023, 2:45 am mohamedatef98, ***@***.***> wrote:
Hello @getsettalk <https://github.com/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
—
Reply to this email directly, view it on GitHub
<#156 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALY3KNAOH7EKTJE5VUUCOF3X73YPFAVCNFSM6AAAAAA5EXCH76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRXGE4TQNRYGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@getsettalk 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. |
Oh , than you can make a new npm package with thats code ... And I will use
your package
…On Wed, 18 Oct 2023, 4:58 pm mohamedatef98, ***@***.***> wrote:
@getsettalk <https://github.com/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.
—
Reply to this email directly, view it on GitHub
<#156 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALY3KNGEHODN2NGLDWRXIR3X764OLAVCNFSM6AAAAAA5EXCH76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRYGI2TCMBTGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi when i going to watch our device oriantion than showing this error :
ERROR TypeError: Cannot read property 'setState' of undefined, js engine: hermes
Here is code 🤞 :
this is screenshots:
please fix as soon as possiable
The text was updated successfully, but these errors were encountered: