我是reactJS和UI的新手,我想知道如何从reactJS代码中进行简单的基于休息的POST调用.
如果有任何示例,那将非常有帮助.
谢谢.
我的应用程序屏幕有一个带有少量文本输入的View组件.我无法禁用文本输入.有没有办法可以禁用完整的View?
PS:通过禁用View组件我的意思是组件呈现但对任何操作都没有响应.
是否有可能使用Facebook的React JavaScript框架为iOS和Android构建应用程序,提供与本机应用程序几乎相同的性能?
我想知道如何设置.flowConfig以便在React-Native项目上使用flow.我创建了一个空的.flowConfig文件但是只要我在JS源文件中包含react-native模块并使用flow检查此文件,flow就会显示'not_found'错误消息.
我正在尝试使用React Native启动并运行,我在Xcode中看到以下消息:
端口8081已在使用中,打包程序未运行或未正常运行
命令/ bin/sh失败,退出代码为2
我去了React Native故障排除页面并尝试终止端口8081进程,但我仍然遇到同样的问题.
这是我在Xcode中看到的截图:
任何帮助将完全赞赏.
我喜欢在事件触发时将属性属性/ 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)
我希望我的代码清楚.
我通过将我的文本转换为小写并将其索引与-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) 不确定是什么导致了这个问题..昨天工作正常.今天,当我尝试运行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) 我遇到一个问题,我在多个组件中基于AsyncStorage中的相同键设置了State.由于状态是在componentDidMount中设置的,并且这些组件不一定在导航时卸载和装载,因此状态值和AsyncStorage值可能不同步.
这是我能做的最简单的例子.
一个只是设置导航和应用程序.
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在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) 我正在学习如何使用本机生成一个移动应用程序但每次我在终端运行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) 我正在使用 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)
我想要实现的是我应该能够识别哪个输入字段触发了事件,并插入了值。
在尝试构建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) 我正在研究'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-native ×13
reactjs ×9
javascript ×4
react-native ×3
android ×1
facebook ×1
html ×1
ios ×1
native-base ×1
node.js ×1
npm ×1
react-jsx ×1
react-router ×1
reactjs-flux ×1
xcode ×1