标签: reactjs-native

如何从ReactJS代码进行休息后调用?

我是reactJS和UI的新手,我想知道如何从reactJS代码中进行简单的基于休息的POST调用.

如果有任何示例,那将非常有帮助.

谢谢.

reactjs reactjs-flux reactjs-native

115
推荐指数
7
解决办法
16万
查看次数

我可以在本机中禁用View组件吗?

我的应用程序屏幕有一个带有少量文本输入的View组件.我无法禁用文本输入.有没有办法可以禁用完整的View?

PS:通过禁用View组件我的意思是组件呈现但对任何操作都没有响应.

javascript facebook reactjs reactjs-native react-native

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

为iOS和Android构建具有原生性能的混合React应用程序

是否有可能使用Facebook的React JavaScript框架为iOS和Android构建应用程序,提供与本机应用程序几乎相同的性能?

android ios reactjs reactjs-native

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

如何设置本机反应使用流量?

我想知道如何设置.flowConfig以便在React-Native项目上使用flow.我创建了一个空的.flowConfig文件但是只要我在JS源文件中包含react-native模块并使用flow检查此文件,flow就会显示'not_found'错误消息.

reactjs-native

17
推荐指数
1
解决办法
9630
查看次数

React Native - 端口8081已在使用中,打包器未运行或未正常运行Command/bin/sh失败,退出代码为2

我正在尝试使用React Native启动并运行,我在Xcode中看到以下消息:

端口8081已在使用中,打包程序未运行或未正常运行

命令/ bin/sh失败,退出代码为2

我去了React Native故障排除页面并尝试终止端口8081进程,但我仍然遇到同样的问题.

这是我在Xcode中看到的截图:

错误截图

任何帮助将完全赞赏.

xcode reactjs-native

15
推荐指数
5
解决办法
3万
查看次数

ReactJS中的子父组件通信

我喜欢在事件触发时将属性属性/ props/state值从子组件发送到父组件onDrag.我找不到合适的文件.

这是我的代码:

/*** @jsx React.DOM */
var APP=React.createClass({
  getInitialState:function()
  {
     return {url:'http://www.youtube.com/embed/XGSy3_Czz8k'}
  },
  handleDrag:function(vidurl)
  {
    alert(vidurl);    //i need to get child component url here.
  },
  render:function(){
    return  <div>
               <VideoFrame  src={this.state.url} />
               <hr/>
           <videos handle={this.handleDrag(vidurl)} />
        </div>
  }
});

var VideoFrame=React.createClass({
  render:function(){
    return  <div>
          <iframe width="420" height="315"  src={this.props.src}>
          </iframe>     
        </div>
  }
});

var videos=React.createClass({
  getInitialState:function()
  {
    return {vidurl:'http://www.youtube.com/embed/XGSy3_Czz8k'}
  },
  render:function()
  {
    return  <img src="http://upload.wikimedia.org/wikipedia/en/a/a6/Size_Small.PNG" onDrag={this.props.handle.bind(this.state.vidurl)}></img> //trying to send state value from here
  }
});

React.renderComponent(<APP />, document.body);      
Run Code Online (Sandbox Code Playgroud)

我希望我的代码清楚.

javascript reactjs react-jsx reactjs-native

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

ReactJS toLowerCase不是一个函数

我通过将我的文本转换为小写并将其索引与-1进行比较来进行比较,以便为特定字段赋予一些值ReactJS,但我在JavaScript控制台中收到此错误:

未捕获的TypeError:props.filterText.toLowerCase不是函数

var props = this.props;
var rows = this.props.episodes
    .filter(function(episode){
        return episode.title.toLowerCase().indexOf(props.filterText.toLowerCase()) > -1;
    })
    .map(function(episode){
       return <EpisodeRow key={episode.title} episode={episode}/>
    });
Run Code Online (Sandbox Code Playgroud)

html javascript reactjs reactjs-native

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

(node:53177)UnhandledPromiseRejectionWarning:未处理的promise拒绝(拒绝id:2):TypeError:无法读取未定义的属性"message"

不确定是什么导致了这个问题..昨天工作正常.今天,当我尝试运行react-native run-android时.我收到这个错误.有任何想法吗?

Starting JS server...
Running adb -s 3f71ece6 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

(node:53177) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'message' of undefined
Run Code Online (Sandbox Code Playgroud)

reactjs-native react-native

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

react-native组件生命周期方法不会在导航上触发

我遇到一个问题,我在多个组件中基于AsyncStorage中的相同键设置了State.由于状态是在componentDidMount中设置的,并且这些组件不一定在导航时卸载和装载,因此状态值和AsyncStorage值可能不同步.

这是我能做的最简单的例子.

组件A.

一个只是设置导航和应用程序.

var React = require('react-native');
var B = require('./B');

var {
    AppRegistry,
    Navigator
} = React;

var A = React.createClass({
    render() {
        return (
            <Navigator
                initialRoute={{
                    component: B
                }}
                renderScene={(route, navigator) => {
                    return <route.component navigator={navigator} />;
                }} />
        );
    }
});

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

组件B.

B在mount上从AsyncStorage读取,然后设置为state.

var React = require('react-native');
var C = require('./C');

var {
    AsyncStorage,
    View,
    Text,
    TouchableHighlight
} = React;

var B = React.createClass({
    componentDidMount() {
        AsyncStorage.getItem('some-identifier').then(value => {
            this.setState({
                isPresent: value …
Run Code Online (Sandbox Code Playgroud)

reactjs reactjs-native react-native

5
推荐指数
1
解决办法
9836
查看次数

npm运行弹出后出错

我正在学习如何使用本机生成一个移动应用程序但每次我在终端运行npm运行弹出它给我这个错误在最后我尝试了几个npm版本但我总是得到这个错误

Ejected successfully!
Please consider letting us know why you ejected in this survey:
  goo.gl/forms/iD6pl218r7fn9N0d2
The batch file cannot be found.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-world2@0.1.0 eject: `react-native-scripts eject`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-world2@0.1.0 eject script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm …
Run Code Online (Sandbox Code Playgroud)

node.js npm reactjs reactjs-native

5
推荐指数
0
解决办法
347
查看次数

react Native onChange 事件的名称类型值未定义

我正在使用 NativeBase 来响应本机应用程序。我试图在输入字段上的文本更改时触发事件

<Input style={Styles.VehicleMeterCenter} placeholder={this.props.item['name']} 
                    value={this.state.item.name} onChange={this.onFieldChange}/>
Run Code Online (Sandbox Code Playgroud)

onFieldChange 处理程序如下:-

    onFieldChange(e)
  {

    console.log("Master");
    console.log(e);

    console.log("Native Event");
    console.log(e.nativeEvent);

    const {name,type,value} = e.nativeEvent;
    console.log(name + " : " + type + " : " + value);
    //this.setState({item:{name:val}});
  }
Run Code Online (Sandbox Code Playgroud)

我对得到的输出感到困惑,没有类型、值或名称。我不确定如何分类处理程序是否是从哪个输入字段触发的,因为这些结构中没有此类信息。

上面代码的输出:

    10:40:46 AM: Master

10:40:46 AM: {"dispatchConfig":null,"_targetInst":null,"isDefaultPrevented":null,"isPropagationStopped":null,"_dispatchListeners":null,"_dispatchInstances":null,"type":null,"target":null,"eventPhase":null,"bubbles":null,"cancelable":null,"defaultPrevented":null,"isTrusted":null,"nativeEvent":null}

10:40:46 AM: Native Event

10:40:46 AM: {"target":622,"eventCount":1,"contentSize":{"height":24,"width":399470.46875},"text":"D"}

10:40:46 AM: undefined : undefined : undefined
Run Code Online (Sandbox Code Playgroud)

我想要实现的是我应该能够识别哪个输入字段触发了事件,并插入了值。

javascript reactjs-native native-base

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

尝试生成预捆绑文件时出现BundleURL错误

在尝试构建ios客户端时react-native,我修改了部分AppDelegate.m文件,如下所示(即,用选项2替换选项1):

// OPTION 1
  // Load from development server. Start the server from the repository root:
  //
  // $ npm start
  //
  // To run on device, change `localhost` to the IP address of your computer, and make sure your computer and
  // iOS device are on the same Wi-Fi network.
  //jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];

  // OPTION 2
  // Load from pre-bundled file on disk. To re-generate the static bundle, run
  //
  // $ curl http://localhost:8081/index.ios.bundle …
Run Code Online (Sandbox Code Playgroud)

reactjs reactjs-native

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

在React.Js中,我想验证长度并限制文本字段中的数字,字母数字和下划线符号?

我正在研究'React.js'项目.我想创建3个文本字段,其中,第一个文本字段 - 我想只插入十六进制值.它应该接受0-9的数字和AF和冒号的字母.它应该只接受23个字符(数字,来自AF和冒号的字母).

第二个文本字段 - 它应该只有十六进制值.

第3个文本字段 - 它应仅接受字母数字值(仅限数字和
字母).

第4个文字字段 - 仅字母.

注意:不应接受特殊字符.

请帮我解决这个问题.

示例代码:

constructor(props) {
  super(props);this.state = {showModal: true};
  this.modalFooter = this.modalFooter.bind(this);
  this.modalBody = this.modalBody.bind(this); this.updateState = this.updateState.bind(this);     
};

modalFooter() {
  return (
    <div>
      <BButton name="Cancel" onClickHandler={() => { this.setState({ showModal: false }) }} />
    </div>);
}

modalBody() {
  return (
    <div>
      <br className="Class">
        <br> Hex Value: <input type="text" className="Class" formnovalidate="return isNumber(event)"
          maxLength="23" placeholder="" /></br>
        <br> Addr:  <input type="text" className="Class" maxLength="6" name=""
          placeholder="" /></br><br> Name: <input type="text" …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router reactjs-native

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