我创建了一个新项目使用
react-native init Wevaha
,之后我执行它正常工作然后我根据我的要求修改了示例应用程序再次运行它正常工作但下次运行应用程序时我得到的错误像Run Code Online (Sandbox Code Playgroud)' Application Wevaha has not been registered.This is either due to a require() error during intialization or failure to call
AppRegistry.registerComponent"
我正在将React代码转换为React Native.所以我需要实现单选按钮.
这是我的实例
var LoginPopup=React.createClass({
render:function(){
return(
<View>
<TextInput placeholder="number" keyboardType="numeric"/>
<TextInput placeholder="url" keyboardType="url"/>
</View>
)
}
})
Run Code Online (Sandbox Code Playgroud)
在此组件中,任何类型的keyboardType都不起作用(如数字,网址,电子邮件地址,数字键盘,电话簿等)
在我的场景中,当我关注TextInput时,我正在使用导航器(使用push)移动到另一个场景,我填充列表,在该列表中选择一个值,该值应该填充到TextInput的前一个场景在这种情况下我无法设置选定的值到TextInput的上一个场景.
我通过导航器发送路由对象,但在我的场景中,选择的值应该重新分配给TextInput的前一个场景.这里的TextInput事件结构如下所示
nativeEvent:
{ target: 2175,
pageY: 164.5,
locationX: 131,
changedTouches: [ [Circular] ],
locationY: 16.5,
identifier: 1,
pageX: 146,
touches: [],
timestamp: 6887223.188515 },
target: undefined,
currentTarget: null,
path: undefined,
type: undefined,
eventPhase: undefined,
bubbles: undefined,
cancelable: undefined,
timeStamp: 1445839347722,
defaultPrevented: undefined,
isTrusted: undefined,
isDefaultPrevented: [Function],
isPropagationStopped: [Function],
_dispatchListeners: null,
_dispatchIDs: null }
Run Code Online (Sandbox Code Playgroud)
这两个都不起作用.将值分配给textinput的正确方法是什么.当前对象获取正常,我的问题是将所选值分配给TextInput.
我在这里遵循两种方法
approach1: -
var FirstComponent = React.createClass({
render:function(){
return(<TextInput value="" placeholder="Enter value" onFocus={getData.bind(this)} />)
}
})
function getData(ev){
var target = ev;
this.props.navigator.push({
id:'SecondComponent',
name:'SecondComponent', …
Run Code Online (Sandbox Code Playgroud) 在我的场景中,我使用导航器渲染组件.在该组件中,我执行了一些操作,例如保存记录,然后我动态地向现有组件添加了一个新的prop.但是这里的动态道具在该组件中是不可见的,只有之前的道具才可见.如何使用导航器为组件添加动态道具.
这里我在使用React Native导航器时提供代码我正在调用DisplayCustomSchema组件,如下所示
this.props.navigator.push({
id: 'DisplayCustomSchema',
name: 'DisplayCustomSchema',
org:this.props.org
});
Run Code Online (Sandbox Code Playgroud)
在DisplayCustomSchema组件中,componentDidMount
我调用一个ajax发布它返回一些数据.
var DisplayCustomSchema = React.createClass({
componentDidMount : function(){
ajaxpost(data){//example only
this.props.record=data
//here i am try to move response data to props because I am using this data in saveRecord function but in save record props contain name and org only
}
}
render: function(){
<View>
<TouchableHighlight style={styles.touchButtonBorder} underlayColor="#ffa456" onPress={saveRecord.bind(this,this.props)}>
<Text style={styles.button}>SAVE</Text>
</TouchableHighlight>
</View>
}
})
Run Code Online (Sandbox Code Playgroud)
这里我的问题是为什么数据不会移动到道具
我正在使用CameraRoll组件来获取照片.但我从CameraRoll.js文件中获取未定义
var RCTCameraRollManager = require('NativeModules').CameraRollManager;
Run Code Online (Sandbox Code Playgroud)
这里RCTCameraRollManager获取'undefined'在我的场景中我使用CameraRoll组件同时用于android和IOS.那么如何通过命令提示符更新node_modules文件
这是我的情景
var FlexWrap = React.createClass({
render:function(){
return(<View style={{flexDirection:'row'}}>
<Image source={{uri:profileImage}}
style={{width:100,height:100}}>
</Image>
<View style={{marginLeft:5}}>
<Text style={{marginTop:5,
marginBottom:5,
flexWrap:'wrap'}}>
This sample text
should be wrap
wrap wrap ....
</Text>
<Text style={{marginTop:5,
marginBottom:5,
flexWrap:'wrap'}}>
This sample text
should be wrap
wrap wrap ....
</Text>
</View>
</View>)
}
})
Run Code Online (Sandbox Code Playgroud)
这里
'这个示例文本应该是wrap wrap wrap ....'
是单行,但在我的场景基于窗口宽度自动文本应该换行.这里我flexWrap: 'wrap'
用来包装文本,但是包装文本的正确方法是什么?
请找截图
这是使用flexDirection进行文本换行的工作代码:'row'
var FlexWrap = React.createClass({
render:function(){
return(<View style={{flexDirection:'row'}}>
<Image source={{uri:profileImage}}
style={{width:100,height:100}}>
</Image>
<View style={{marginLeft:5,flex:1}}>//using flex:1
<Text style={{marginTop:5,
marginBottom:5
}}>
This sample text
should be …
Run Code Online (Sandbox Code Playgroud)