react native 中的快速刷新总是完全重新加载应用程序 [英] Fast refresh in react native always fully reload the app

查看:18
本文介绍了react native 中的快速刷新总是完全重新加载应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经在这里被问过好几次了(这里最相关另一个例子),但其中任何一个都没有提出解决方案.所以我有两个问题要问你们:

This question has been asked several times here(here the most relevant,Another example), but no solution has been proposed in any of them. So I have 2 questions to you guys:

  1. 知道为什么它在大型项目中不起作用吗?我的意思是,与项目大小或他包含的包相关的快速刷新是否存在任何已知问题会导致快速刷新停止工作?有什么办法可以解决吗?
  2. 是否有一种方便的方法可以在不使用快速刷新的情况下在应用中编辑内部页面(无需独立运行页面,因为它取决于应用的所有逻辑)?

这个bug真的让我的开发变得非常困难,我很难相信专业的开发人员没有找到解决这个问题的方法,请帮助!

This bug really makes the development really difficult for me, and I find it hard to believe that professional developers have not found a way around this problem, Please help!

我正在使用 expo-cli(v3.26.2 - Expo SDK 38 使用 react-native v0.62)

I'm using expo-cli(v3.26.2 - Expo SDK 38 that using react-native v0.62)

推荐答案

TLDR;

使用没有名称的默认导出总是会导致应用完全重新加载而无需热重新加载!

所以在痛苦了好几个月之后,我无意中发现了一个足够奇怪的效果:我通常用这种语法编写我的反应组件:

So after a lot of months of pain, I accidentally found a strangely enough effect: I usually write my react components in this syntax:

export default ({ ...props }) => {
  ...
};

由于某种原因,更改以这种方式导出的模块总是会导致应用完全重新加载而无需热重新加载!

and for some reason, changing a module that exports that way ALWAYS resulted in a full reload of the app without hot reload!

经过几个月的痛苦,我偶然发现将导出更改为:

after months of pain, accidentally i found out that changing the export to:

const Test = ({ ...props }) => {
  ...
};

export default Test;

完全解决了这个问题,现在热重载工作得很好!
我没有在网上看到一个地方提到过这种效果!

completely fixed the issue and now hot reload works perfectly fine!
I did not saw this effect mentioned in a single place on the internet!

这篇关于react native 中的快速刷新总是完全重新加载应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆