Skip to content
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

improve dev mode and HMR interop #24377

Closed
wants to merge 6 commits into from

Conversation

vonovak
Copy link
Collaborator

@vonovak vonovak commented Apr 9, 2019

Summary

Motivation is following - I'm sure many people encountered this because it has been like this for a long time.

1 . you're developing something on android, HMR and dev mode is enabled
2 . you go to dev settings, you disable dev mode because you want to see how something behaves
3 . you reload the app because that's what is required for the change to take effect
4 . you wait for the bundle to be compiled and served, and when that is done, you get an error message about HMR not being a registered callable module - because HMR is not available when __DEV__ === false (todo screenshot)

this fixes the described case by checking if HMR is enabled and dev mode disabled when reloading (step 3) and disables HMR in that case.

this also fixes the case when dev mode is disabled and without knowing it, you try to enable HRM (will enable both dev hmr and dev mode).

Changelog

[Android] [Changed] - improve developer experience around Dev mode and HMR interop

Test Plan

I used the RN tester app and manually verified it works as intended. See gifs where I proceeded as in the steps given above:

current master - you need to be patient to get to the error screen

master

this branch - HMR gets disabled

fixed

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 9, 2019
@@ -509,6 +513,10 @@ public void onOptionSelected() {
new DevOptionHandler() {
@Override
public void onOptionSelected() {
if (!mDevSettings.isHotModuleReplacementEnabled() && !mDevSettings.isJSDevModeEnabled()) {
Toast.makeText(mApplicationContext, "Dev mode needs to be turned on to enable HMR.", Toast.LENGTH_LONG).show();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the message isn't sufficiently actionable (as opposed to the one above) because of the return afterwards. Could we either make it enable dev mode or change the message to include "Enable Dev mode first to enable HMR"? I think I'd probably prefer it just enabling dev mode and HMR both, and showing the message you have here. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I was gonna suggest this as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer please let me know what you think, thanks

Copy link
Collaborator Author

@vonovak vonovak Apr 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also (that would be something for another PR) - I find that for me, the only reason I go to the "Dev Settings" is to turn off / on the dev mode. I don't do that all too often, but still, perhaps it would make sense to move that option to the dialog, same as with turning on / off the HMR

Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I like it!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @vonovak in 3b1760d.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Apr 11, 2019
@vonovak vonovak deleted the improveHrmAndDevModeInterop branch April 11, 2019 10:47
dsyang pushed a commit to dsyang/react-native that referenced this pull request Apr 12, 2019
Summary:
Motivation is following - I'm sure many people encountered this because it has been like this for a long time.

1 . you're developing something on android, HMR and dev mode is enabled
2 . you go to dev settings, you disable dev mode because you want to see how something behaves
3 . you reload the app because that's what is required for the change to take effect
4 . you wait for the bundle to be compiled and served, and when that is done, you get an error message about HMR not being a registered callable module - because HMR is not available when `__DEV__ === false` (todo screenshot)

this fixes the described case by checking if HMR is enabled and dev mode disabled when reloading (step 3) and disables HMR in that case.

this also fixes the case when dev mode is disabled and without knowing it, you try to enable HRM (will enable both dev hmr and dev mode).

[Android] [Changed] - improve developer experience around Dev mode and HMR interop
Pull Request resolved: facebook#24377

Differential Revision: D14890695

Pulled By: cpojer

fbshipit-source-id: 95b6ff4131c6d05a32aadd09a9d5ed11f602122c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants