小编ben*_*nel的帖子

React Native项目没有index.ios.js或index.android.js

嗨,我是React Native的新手.我按照下面的链接建立我的第一个项目,但发现没有index.ios.js或index.android.js供我编辑:

https://facebook.github.io/react-native/docs/getting-started.html

只创建了App.js,我可以知道如何分别编辑ios和android吗?谢谢!

reactjs react-native

34
推荐指数
2
解决办法
2万
查看次数

我如何使用for循环与反应?

我很反应,我真正想要的是一个简单的for循环,为我的数组中的每个用户创建menuitem元素,标题是它们的名字.所以这就是我写它的方式,但我不知道怎么做反应.我认为它应该是一张地图,但我似乎无法让它工作,或希望任何人在这里可以帮助我.

for (var i = 0; i < Users.length; i++) {
  <MenuItem eventKey=[i]>User.firstname[i]</MenuItem>
}
Run Code Online (Sandbox Code Playgroud)

for-loop reactjs bootstrap-4

14
推荐指数
2
解决办法
2万
查看次数

Firebase云功能错误:连接ECONNREFUSED

我正在尝试使用Firebase云功能根据其API创建Kik Messenger bot .我正在使用Blaze Plan.我正在尝试回复我的机器人收到的消息.我可以在我的API上收到消息,但是当我尝试回复它们时,我收到错误消息.错误不是来自请求回调.我在Firebase控制台上看到了错误.

错误:连接ECONNREFUSED 72.14.246.44:443

at object.exports._errnoException(util.js:1018:11)
at exports._exceptionWithHostPort(util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete](net.js:1086:14)
code:'ECONNREFUSED' ,
错误号:'ECONNREFUSED',
系统调用:'connect',
地址:'72 .14.246.44',
port:443

对Kik Messenger API的请求适用于本地和远程节点/快速应用程序.我尝试在云函数上使用kik-node,但它给出了相同的结果.到目前为止我发现的是https://auth.kik.com解析到亚马逊并https://api.kik.com解析为Google Hosting.我认为他们也在使用Firebase Cloud Functions作为他们的API.它们是否可能被阻止入站请求?这是我尝试过的示例代码.

exports.messagepost = functions.https.onRequest((req, res) => {
  // Gives the error below
  // {
  //  Error: connect ECONNREFUSED 72.14.246.44:443
  //   at Object.exports._errnoException (util.js:1018:11)
  //   at exports._exceptionWithHostPort (util.js:1041:20)
  //   at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
  //   code: 'ECONNREFUSED',
  //   errno: 'ECONNREFUSED',
  //   syscall: 'connect',
  //   address: '72.14.246.44', …
Run Code Online (Sandbox Code Playgroud)

node.js firebase kik google-cloud-functions

11
推荐指数
1
解决办法
1474
查看次数

React-Native AsyncStorage.clear()在IOS上失败

我正在使用AsyncStorage.clear()它在Android上工作得很好但是当使用iOS平台(真实设备)运行时我收到此错误并且无法在线找到任何关于它的信息.

Error: Failed to delete storage directory.Error Domain=NSCocoaErrorDomain Code=4 "“RCTAsyncLocalStorage_V1” couldn’t be removed." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/281A6456-6CB2-47D4-AD04-3EB26A1B9506/Documents/RCTAsyncLocalStorage_V1, NSUserStringVariant=(
    Remove
), NSUnderlyingError=0x174049480 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Error: Failed to delete storage directory.Error Domain=NSCocoaErrorDomain Code=4 "“RCTAsyncLocalStorage_V1” couldn’t be removed." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/281A6456-6CB2-47D4-AD04-3EB26A1B9506/Documents/RCTAsyncLocalStorage_V1, NSUserStringVariant=(
    Remove
), NSUnderlyingError=0x174049480 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
    at convertError (http://192.168.1.33.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:52255:13)
    at http://192.168.1.33.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:52109:18
    at MessageQueue.__invokeCallback (http://192.168.1.33.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:2060:16)
    at http://192.168.1.33.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:1853:15
    at MessageQueue.__guard (http://192.168.1.33.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:1991:9)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (http://192.168.1.33.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:1852:13)
    at t (file:///Applications/React%20Native%20Debugger.app/Contents/Resources/app.asar/js/RNDebuggerWorker.js:1:14632)
Run Code Online (Sandbox Code Playgroud)

ios react-native asyncstorage

10
推荐指数
2
解决办法
3149
查看次数

'd3'中未找到导出'时间'(导入为'd3')

我是新手,使用D3和React.我的反应应用程序是由create-react-app创建的.在我的react组件中,我使用导入d3import * as d3 from 'd3'

我的代码如下:

    this.xScale = d3.time.scale()
        .domain(d3.extent(this.props.data, function (d) {
            return d[_self.props.xData];
         }))
    .rangeRound([0, this.w]);

    this.yScale = d3.scale.linear()
        .domain([0,d3.max(this.props.data,function(d){
            return d[_self.props.yData]+_self.props.yMaxBuffer;
        })])
        .range([this.h, 0]);

    this.area = d3.svg.area()
        .x(function (d) {
            return this.xScale(d[_self.props.xData]);
        })
        .y0(this.h)
        .y1(function (d) {
            return this.yScale(d[_self.props.yData]);
        }).interpolate(this.props.interpolations);
Run Code Online (Sandbox Code Playgroud)

得到了编译错误:

'd3'中未找到导出'时间'(导入为'd3')

npm install d3 --save在我的项目目录下导入d3 .

任何人都有想法是什么问题?

d3.js reactjs

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

withRouter,connect()和react-compose

我正在使用react-redux连接功能和withRouter功能,我也试图在compose()这里使用.这是代码:

export default compose (
    withRouter,
    connect(mapStateToProps)
)(Dashboard);
Run Code Online (Sandbox Code Playgroud)

但是我收到了下一个错误:

Uncaught TypeError: Converting circular structure to JSON
    at Object.stringify (<anonymous>)
    at wrapWithConnect (connectAdvanced.js:84)
    at applyFunctor (index.js:124)
    at index.js:144
    at Array.reduce (<anonymous>)
    at ComposedComponent (index.js:143)
    at ReactCompositeComponent.js:305
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponentWrapper._constructComponentWithoutOwner (ReactCompositeComponent.js:304)
    at ReactCompositeComponentWrapper._constructComponent (ReactCompositeComponent.js:279)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:187)
    at Object.mountComponent (ReactReconciler.js:45)
    at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:370)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:257)
    at Object.mountComponent (ReactReconciler.js:45)
    at ReactDOMComponent.mountChildren (ReactMultiChild.js:236)
    at ReactDOMComponent._createInitialChildren (ReactDOMComponent.js:703)
    at ReactDOMComponent.mountComponent (ReactDOMComponent.js:522)
    at Object.mountComponent (ReactReconciler.js:45)
    at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:370) …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router redux react-redux

8
推荐指数
1
解决办法
6027
查看次数

'SFSafariViewController'仅适用于iOS 9.0或更高版本(React Native Build)

我可以通过Expo在模拟器中运行我的React Native应用程序,但是当我尝试使用Xcode构建它时,我收到此错误:

'SFSafariViewController'仅适用于iOS 9.0或更高版本(React Native Build)

这些是我构建的步骤.

  1. npm run eject
  2. 弹出'ExpoKit'选项
  3. cd 进入ios目录
  4. pod install
  5. 在Xcode中打开xcworkspace文件
  6. 在项目和目标中,我将Deployment Target值更改为11.0
  7. 将构建运行到iOS版本11模拟器

然后构建失败,出现上述7个错误.我正在使用Xcode版本9.0,Pods版本1.3.1.

任何帮助将不胜感激.

xcode ios react-native

7
推荐指数
1
解决办法
2129
查看次数

本机IllegalViewOperationException:尝试为具有未知标记的视图设置本地数据

我正在开发一个react本机应用程序,在我将原始版本从0.47.2升级到0.50.3之后,我得到了一个随机崩溃未捕获的异常只发生在Android上:IllegalViewOperationException:尝试为具有未知标记的视图设置本地数据.

下面是崩溃日志

Fatal Exception: com.facebook.react.uimanager.IllegalViewOperationException: Trying to set local data for view with unknown tag: 36
       at com.facebook.react.uimanager.UIImplementation.setViewLocalData(UIImplementation.java:246)
       at com.facebook.react.uimanager.UIManagerModule$3.runGuarded(UIManagerModule.java:357)
       at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:21)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
       at android.os.Looper.loop(Looper.java:158)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
       at java.lang.Thread.run(Thread.java:818)
Run Code Online (Sandbox Code Playgroud)

我想问一下是否有人知道崩溃的根本原因,以及如何解决它.

我也谷歌搜索如何捕获异常并找到帖子http://coofee.github.io/post/catch-react-native-IllegalViewOperationException/ 但不知道如何完全做到这一点.

谢谢.

android react-native

6
推荐指数
0
解决办法
1603
查看次数

在特定屏幕上使用react-navigation修改后退按钮

我正在使用react-navigation我的导航库,我想知道如何更改react-navigation特定屏幕的"后退"按钮(由自动添加)功能?

我的意思是不是在屏幕堆栈中走一步,而是希望它在堆栈中向后走2步.或者通过给它一个屏幕名称手动完成(再次只在一个组件上).

谢谢.

reactjs react-native react-navigation

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

错误:Minified React错误#130

我在文件./MyInput.react.js中有以下ReactJs组件

import React from 'react';

export default class MyInput extends React.Component {
  constructor(props) {
    super(props);
    this.id = getNextId();

    this.onChange = this.onChange.bind(this);
  }
  onChange(e) {
    this.props.onChange(e.target.value);
  }
  render() {
    return (
      <label htmlFor={this.id}>
        {this.props.label}      
        <input
          id={this.id}
          value={this.props.value} 
          onChange={this.onChange}
          />
      </label>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

现在我尝试将它导入./index.js,如下所示:

import {MyInput} from './MyInput.react';
Run Code Online (Sandbox Code Playgroud)

控制台返回错误:

Error: Minified React error #130
Run Code Online (Sandbox Code Playgroud)

您刚刚遇到的错误的全文是:

Element type is invalid: expected a string (for built-in components) or 
a class/function (for composite components) but got: undefined.
Run Code Online (Sandbox Code Playgroud)

这有什么问题?

ecmascript-6 reactjs es6-class

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