React未考虑本机捆绑包更改

React native bundle changes not taken in account

本文关键字:包更改 本机 React      更新时间:2023-09-26

我有一个使用此方法的组件:

onRegionChangeComplete = (region) => {
  var mapHeight = windowHeight - 124;
  var centerCircleLatitude = region.latitude + (mapHeight -  windowWidth  - (topSize * 2)) * (region.latitudeDelta / (2 * mapHeight));
  var centerCircleLongitude = region.longitude;
  RestaurantsActions.setRegion(radius, region.longitude, region.latitude, region.longitudeDelta, region.latitudeDelta, centerCircleLongitude, centerCircleLatitude, windowWidth, mapHeight);
  this.setState({data: RestaurantsStore.filteredRestaurants()});
  this.setState({isChanging : false});
  this.setState({index : 0});
  this.refs.carousel.goToPage(this.state.index, 'annotationPress');
}

我把上面删除最后两行的代码改为:

onRegionChangeComplete = (region) => {
  var mapHeight = windowHeight - 124;
  var centerCircleLatitude = region.latitude + (mapHeight -  windowWidth  - (topSize * 2)) * (region.latitudeDelta / (2 * mapHeight));
  var centerCircleLongitude = region.longitude;
  RestaurantsActions.setRegion(radius, region.longitude, region.latitude, region.longitudeDelta, region.latitudeDelta, centerCircleLongitude, centerCircleLatitude, windowWidth, mapHeight);
  this.setState({data: RestaurantsStore.filteredRestaurants()});
  this.setState({isChanging : false});
}

当运行react原生bundle时,我检查输出文件,它仍然有我删除的那两行。是否还有缓存或其他东西?

我的捆绑包命令行:

react-native bundle --dev true --entry-file index.ios.js --bundle-output ios/main.jsbundle --verbose --platform ios

我使用的是react native 0.16.0

好的,我发现捆绑包使用了打包程序的缓存版本。我删除它通过做:

rm -f $TMPDIR/react-packager*

然后我重新运行bundle命令,它运行得很好。