2016-11-29 119 views
0

初学者引导反应原住民和火力地堡React Native和Firebase的初学者指南,修改示例?

2016年7月14日

大卫东 开发者布

你好,我的名字是商事板垣。 我试图让这个例子来处理事件管理。 最初的例子是使用firebase数据库的杂货店。 我的意图是构建像Facebook的F8app这样的事件管理工具。

Screen1用于事件的注册管理,选择事件并注册。 屏幕2是用于接待员管理,

屏幕2是空的,它 似乎从屏幕1转移而不能正常工作到画面2

 
    DB’s class is as follows. 
    Event class(Event, day, start time , end time, etc) 
    Registration class(User, Event etc)

Screen 1 Outline of Firebase database management. 
this.itemsRef = this.getRef().child('items’); For Event Class reference pointer 
this.userRef = this.getRef().child('user’);  For User Registration Class 

getRef() {return firebaseApp.database().ref();} 

变种用户= firebase.auth()currentUser。获取用户帐号 this.setState({user:user});为使

render section 
    mail=this.state.user.email; 
    console.log('mail = ' + mail); 
    mail=mail.substring(0,mail.indexOf("@")); 
    console.log('after modify mail = ' + mail); 
    this.userRef = firebaseApp.database().ref('user/' + mail); 
    this.userRef.push(new User(event,password,user); 
This screen was OK and DB was created as follows. 
rera06x 
* 
     -KXih12q_2XE24UQ6S7p 
    * 
event: 
     * 
password: 
* 
user 
    * 
_key: 
    * 

标题: * -KXih_ZHuf12YujhC0Bl * 事件 * _key: * 标题: * 密码 * _key: * 标题: * 用户 * _key: * title: * -KXikRGmj9LTENY3yBDr * 事件 * _key: * 标题: * 密码 * _key: * 标题: * 用户 * _key: * 标题:

Screen 2 for Receptionist and Firebase database process's outline 
var user = firebase.auth().currentUser;  same as screen 1, to get  user account 

componentDidMount() { 
this.listenForItems(this.userRef); 

    this.userRef = firebaseApp.database().ref('user/' + mail); 

listenForItems(userRef) {       In this section, The Registration list was get, 
userRef.on('value', (snap) => {    

// get children as an array var user = []; snap.forEach((child) => { user.push({ event: child.val().event, _key: child.key }); }); this.setState({ dataSource: this.state.dataSource.cloneWithRows(user) }); }); } render() { return ( <ListView dataSource={this.state.dataSource} renderRow={this._renderItem.bind(this)} enableEmptySections={true} style={styles.listview}/> abridgment _renderItem(user) { const onPress =() => { Alert.alert( 'Registration', null, [ {text: 'Registration', onPress: (user) => uketukeExec }, {text: 'Cancel', onPress: (user) => console.log('Cancelled')} ] ); }; return ( <ListItem1 item={user} onPress={onPress} /> ★★★★★★★★★★★ ); } } class ListItem1 extends Component { render() { return ( <TouchableHighlight onPress={this.props.onPress}> <View style={styles.li}> <Text style={styles.liText}>{this.props.item.event}</Text>  This process does not work </View> </TouchableHighlight> abridgement

任何意见将不胜感激。 Shoji

+0

错误是follows.Object并不像一个孩子做出反应有效(发现:与键{_key,标题}对象)。如果您打算渲染一组儿童,请改用数组,或者使用React加载项中的createFragment(object)封装对象。检查文字的呈现。 – itagaki

+0

我的错误是浮动。对象作为React子项无效(找到:具有键{_key,title}的对象)。如果您打算渲染一组儿童,请改用数组,或者使用React加载项中的createFragment(object)封装对象。检查文字的呈现。 – itagaki

+0

我想渲染1项道路是“rera06x/event/title”。下一个错误显示collectionas子项的呈现是错误的。原始应用程序仅适用于grosary 1项目。所以,增加一些项目是这个错误的原因? – itagaki

回答

0

最后,经过深入调试,我发现了这个BUG。 错误的原因是我的穷人程序。 我的意图是快乐的。

无论如何,React Native和Firebase 的初学者指南是该领域最好的文章,尤其是像我这样的新用户。

感谢 商事