React Native中的快速刷新始终会完全重新加载应用程序 [英] Fast refresh in react native always fully reload the app
问题描述
此问题已在此处多次提出(另一个示例),但在任何一个中都未提出解决方案.所以我有两个问题要问你们:
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:
- 有人知道为什么它在大型项目中不起作用吗?我的意思是,快速刷新是否存在与项目或他所包含的软件包的大小有关的已知问题,这些问题会使快速刷新停止工作?有什么办法可以解决?
- 是否有一种方便的方法可以在不使用快速刷新的情况下(无需独立运行页面,因为它取决于应用程序的所有逻辑)来编辑应用程序中的内部页面?
这个错误确实使开发工作对我来说真的很困难,我很难相信专业的开发人员还没有找到解决这个问题的方法,请帮忙!
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-使用react-native v0.62的Expo SDK 38)
I'm using expo-cli(v3.26.2 - Expo SDK 38 that using react-native v0.62)
推荐答案
TLDR;
使用不带名称的默认导出总是会导致应用程序完全重载而不会热重载!
因此,经过几个月的痛苦,我无意间发现了一种奇怪的效果:我通常使用以下语法编写我的react组件:
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屋!