我有一个从firebase读取数据的功能,我想将检索到的数据传递给其他非子组件...以下是我的代码。...
readdata() {
var ref = fire.database().ref('Employers');
ref.on("value", (snapshot) => {
var joblist = [];
snapshot.forEach((child)=> {
child.forEach((child1)=>{
joblist.push(child1.val())
let newState = [];
for (let item in joblist) {
newState.push({
id: item,
title: joblist[item].Title,
description: joblist[item].Description,
location: joblist[item].Location,
rateperhour: joblist[item].RatePerHour,
});
this.setState({
slidercontents: newState
});
}
})
this.setState({empname : child.key})
});
});
}