2016-11-29 74 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 的初學者指南是該領域最好的文章,尤其是像我這樣的新用戶。

感謝 商事