相关疑难解决方法(0)

为什么React Native 0.30没有从iPhone设备上的开发服务器获得更改?

自从我升级到React Native 0.30后,我的物理iPhone上的构建从预先捆绑的文件而不是开发服务器加载.查看更改的唯一方法是再次构建和运行应用程序.以前,我可以通过刷新立即在iPhone上看到更改.

如果我使用模拟器,那么从开发服务器更改负载就好了.

这是我的AppDelegate.m:

#import "AppDelegate.h"

#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"upool"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

@end
Run Code Online (Sandbox Code Playgroud)

react-native

6
推荐指数
2
解决办法
1562
查看次数

React Native:无法解析模块

我有一个非常简单的React Native项目,我正努力工作.这是一个iOS项目,它只是将一个RCTRootView添加到UIViewController中.当我从网络浏览器点击网址时,我得到:

Unable to resolve module `/src/components/HelloReact` from `/Users/myusername/Desktop/DemoReact/index.ios.js`: Directory /src/components/HelloReact doesn't exist.
Run Code Online (Sandbox Code Playgroud)

index.ios.js

'use strict';

import { AppRegistry } from 'react-native';
import HelloReact from '/src/components/HelloReact';

AppRegistry.registerComponent('HelloReact', () => HelloReact);
Run Code Online (Sandbox Code Playgroud)

HelloReact.js

import React, { Component } from 'react';
import { AppRegistry, Text } from 'react-native';

export default class HelloReact extends Component {
  render() {
    return (
      <Text style={{fontWeight: 'bold'}}>
        I am bold
        <Text style={{color: 'red'}}>
          and red
        </Text>
      </Text>
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

我对如何解决这个问题感到茫然.我尝试了以下所有方法:

  • npm start
  • npm start --reset-cache
  • 删除了node_modules目录并重新安装
  • 卸载并重新安装的节点,守望者,react-native和npm …

objective-c node.js ios reactjs react-native

2
推荐指数
1
解决办法
3451
查看次数

标签 统计

react-native ×2

ios ×1

node.js ×1

objective-c ×1

reactjs ×1