-
Notifications
You must be signed in to change notification settings - Fork 20
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
Hot reloading breaks media queries #29
Comments
Thanks @dmeij! I'll have a look to see if there's something that we can do to fix this. |
I did a quick testing with your example, and it was working correctly for me on Android, so I could not reproduce the issue. Could you provide a bit more info about your project, or maybe an example that I can try out? |
I think I found the problem. After changing the configChanges in my Manifest file from: android:configChanges="keyboardHidden|orientation" to android:configChanges="keyboard|keyboardHidden|orientation|screenSize" the problem doesn't occur anymore. My mistake, screenSize was missing which reloaded the app for some reason. Only now if I rotate my screen, the background-color isn't changing anymore, only when I save my file and hot reloading triggers. Don't know if this is the normal behavior or should the background color change when the screen rotates without reloading? |
The reason why the background does not change when you rotate is that the React components do not automatically re-render if they don't need to when the orientation change happens. I made a small library to fix that issue. It will force the components to re-render whenever the orientation changes: |
Thnx, is it correct that the re-render will reset the navigation state when using React Navigation? Can I do something about that? Because now when I rotate my screen when I'm not on the root page it will re-render en show me the route page again instead of the page I was viewing. |
I'm not sure as I have not tested, but I guess that you would only need to wrap the views that are inside the router. So you could create a wrapping component that you would use for each route in your navigator. |
JS file
Style file:
When change the screen from landscape to portrait the color of the button with style "button1" changes correct. But when I save my JS file which triggers hot reloading, the background-color changes to the initial value. Tested it on Android.
The text was updated successfully, but these errors were encountered: