反应导航:为什么在`src`中更改相应文件时,`lib`目录中的缩小文件不会更新?

问题描述 投票:0回答:1

我在React Native应用程序中使用Material Top Tab导航器。具体来说,我使用在createMaterialTopTabNavigator()中找到的函数react-navigation-tabsreact-navigation-tabs包含文件lib -> module -> views -> MaterialTopTabBar.js,它是与src -> views -> MaterialTopTabBar.tsx相对应的缩小文件。我想在MaterialTopTabBar.tsx中进行一些更改,因为我可能会分叉模块,但是当我编辑MaterialTopTabBar.tsx时,即使重新运行react-native run-iosMaterialTopTabBar.js(在lib中)也不会得到更新。当我直接编辑MaterialTopTabBar.js(缩小的文件)时,更改的确显示了。

有人知道我更改MaterialTopTabBar.js并重新生成项目时为什么MaterialTopTabBar.tsx没有得到更新吗?

UPDATE:我认为是MaterialTopTabBar.tsx在模块交付之前被编译为MaterialTopTabBar.js,而不是在我构建项目时。解决问题的一种方法是将MaterialTopTabBar.tsx中的Typescript代码手动转换为JS,然后将其粘贴到MaterialTopTabBar.js中。

reactjs typescript react-native react-navigation react-native-navigation
1个回答
0
投票

不是全部数据。我不知道bundler proccess是否由webpack或其他运行。但让我们以CRA为例。 webpack-dev-server

具有以下内容

// for some reason broken when imported through webpack. If you just want to
// use an image, put it in `src` and `import` it from JavaScript instead.
        contentBase: paths.appPublic,
        contentBasePublicPath: paths.publicUrlOrPath,
        // By default files from `contentBase` will not trigger a page reload.
        watchContentBase: true,
        // Enable hot reloading server. It will provide WDS_SOCKET_PATH endpoint

所以您需要找到地方是contentBase且声明了东西

© www.soinside.com 2019 - 2024. All rights reserved.