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

Let developer "Enable Live Reload" programmatically #2064

Closed
fatuhoku opened this issue Jul 20, 2015 · 3 comments
Closed

Let developer "Enable Live Reload" programmatically #2064

fatuhoku opened this issue Jul 20, 2015 · 3 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@fatuhoku
Copy link

I want an alternative way of activating this option without necessarily going through the RN dev menu. Reasons for this may be because the menu cannot be activated from the modal (see #2063), or that your shake gesture is already bound to something else useful in your app.

RN appears to persist the Enable Live Reload preference across sessions — I'm assuming it uses NSUserDefaults or some such, so a simple solution might be to document the exact key for which this preference is stored. I could then write into that key the value I want (YES, always) and enable it without the UI.

@ide
Copy link
Contributor

ide commented Jul 20, 2015

Yeah it's stored in NSUserDefaults as a dictionary. Here's the documentation :P https://github.com/facebook/react-native/blob/master/React/Base/RCTDevMenu.m#L191

@fatuhoku
Copy link
Author

@ide Haha. Works a charm. The exact snippet I used:

    // Enables live reload programmatically...!
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    NSMutableDictionary *settings = [(NSDictionary *)[defaults valueForKey:@"RCTDevMenu"] mutableCopy];
    settings[@"liveReloadEnabled"] = @YES;

    [defaults setObject:settings forKey:@"RCTDevMenu"];
    [defaults synchronize];

@faceyspacey
Copy link

it seems to be different now. How would I go about this now? I just want to be able to assign a button in my app the ability to reload so I can just press it, or call a command from the chrome console. This is especially important with hot loading since regular reload isn't used anymore.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 22, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants