【发布时间】:2021-09-09 15:08:46
【问题描述】:
[]
我有 3 个录制屏幕,我想在一个页面上列出用户信息。但每个屏幕都分配了一个单独的 pushKey。我也无法使用这些 pushKeys 访问代码部分中的数据库
{
const user = firebase.auth().currentUser.uid;
const db = firebase.database();
const ref = db.ref('kullaniciBilgiler/'+`${user}`);
ref.once('value', (snapshot) => {
var data=snapshot.val();
console.log(data)
}, (errorObject) => {
console.log('The read failed: ' + errorObject.name);
});
export default class profile extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
var box = [];
for(let i = 0; i <= 5; i++){
box.push(
<View style={{flexDirection:'row'}}>
<View style={styles.textBox}>
<Text style={styles.textMid}>Soyisim</Text>
</View>
<View style={styles.inputView}>
<TextInput
onChangeText={(text)=>setList(text)}
style={styles.input}
/>
</View>
</View>
)
}
return (
<ScrollView>
<SafeAreaView style={styles.container} >
<View style={styles.profilePhoto}>
<Image
style={{
width: 100,
height: 100,
resizeMode: 'contain',
marginTop:40
}}
source={
require('../../image/logo.png')
}
/>
</View>
<View style={styles.profileDetails}>
{box}
</View>
</SafeAreaView>
</ScrollView>
);
}
}
}
我无法获取推送分配的随机密钥,也无法访问数据库中的信息
[]
_handleSubmit = (values) => {
auth()
.createUserWithEmailAndPassword(values.email, values.password)
.then(() => {
userId = firebase.auth().currentUser.uid;
if (userId) {
var database = firebase.database().ref('kullaniciBilgiler/').child(userId).push();
database.set({
name: values.name,
surname: values.surname,
email: values.email,
}).then(() => console.log('okey'));
}
这个注册码
【问题讨论】:
-
数据库图片位于顶部链接
-
您应该使用
.set()而不是.push(),这样所有用户信息都在用户UID 节点下。您能否将包含push()ing 数据的代码分享给 Firebase? -
当然,请一分钟
-
您能否编辑您的问题并将其添加为文本以便于复制和解释?
标签: javascript firebase react-native firebase-realtime-database