React Native:世博会的快速刷新功能仅在应用程序中有效.js在世博会GO移动应用程序中正确运行



文件夹结构如下

app/
├─node_modules/
├─src/
│├─RepositoryItem。jsx
│├─rammstein。jsx
│├─rammstein。Jsx
├─rammstein。. json
├─README. jsonmd
├─App.js

RepositoryList和RepositoryItem被导入到Main.jsx中。主要。jsx导入到App.js

如果我修改了App.js或Main.js中的代码,并保存。世博会GO应用程序立即显示更改。

如果修改RepositoryList。jsx或RepositoryItem。JSX组件和保存,快速刷新发生,但不显示更改。只有当我手动重新加载应用程序。

如果修改RepositoryList。jsx组件和Main.jsx。Main中的变化。在RepositoryList中立即显示jsx的变化。JSX仅在手动重新加载后使用。

也如果我改变RepositoryItem或RepositoryList…"刷新…使用快速刷新显示;但这些变化并没有反映在应用程序

我在手机和平板电脑上都试过了,两个设备都出现了问题。

有办法解决这个问题吗?

您正在使用JSX文件(RepositoryItem.jsx;RepositoryList.jsx;Main.jsx)。你是否尝试过将扩展更改为JS?(Javascript)即:RepositoryItem.js

快速刷新适用于嵌套在子文件夹中的文件,如RepositoryList.jsRepositoryItem.js

为什么它没有为我刷新是因为在RepositoryList中我返回FlatList组件,其中renderItemRepositoryItem。像这样:

return (
<View>
<FlatList
data={repositories}
ItemSeparatorComponent={ItemSeparator}
renderItem={RepositoryItem}
/>
</View>
);

现在的问题是:为什么快速刷新不工作,如果我改变RepositoryItem,这是FlatListrenderItem属性?

相关内容