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

how to disable HMR #313

Open
yinhangfeng opened this issue Nov 10, 2018 · 2 comments
Open

how to disable HMR #313

yinhangfeng opened this issue Nov 10, 2018 · 2 comments

Comments

@yinhangfeng
Copy link

Do you want to request a feature or report a bug?
feature

What is the current behavior?

  • the hot option in parseOptionsFromUrl is always true
  • HMR not compatible with es6 class? must use @babel/plugin-transform-classes
  • HMR make debug hard

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?
metro.config.js give a option to enable/disable HMR

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
Node: 8.11.3
Npm: 6.4.1
MacOS Mojave

@DimitryDushkin
Copy link

DimitryDushkin commented Dec 20, 2018

Here is how for RN >= 57

  1. Create rn-cli.config.js
module.exports = {
    transformer: {
        babelTransformerPath: require.resolve('./scripts/customReactNativeTransformer')
    }
};
  1. Create ./scripts/customReactNativeTransformer.js
const {
    transform,
    getCacheKey,
} = require('metro/src/reactNativeTransformer');

function customTransform(config) {
    config.options.hot = false;
    return transform(config);
}

module.exports = {
    transform: customTransform,
    getCacheKey,
};
  1. Profit!

@stevelizcano
Copy link

stevelizcano commented Jun 25, 2019

I edited your method so that it works with the latest version of RN/Expo 33

mobxjs/mobx-react#690 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants