首先,我正在使用React Native。我从Firebase获取数据,并想快速写入存储区(由Redux提供)。但这行不通。您可以在下面找到我的所有代码:
功能:
async getTumData (uid) {
const {selectedGroupDetail, getSelectedGroupDetail} = this.props;
var yeniGrupDetayi = {};
await firebase.database().ref("/groups/"+uid).once('value').then(
function(snapshot){
yeniGrupDetayi = {...snapshot.val(), uid: uid};
}).catch(e => console.log(e.message));
console.log("FONKSIYON ICERISINDEKI ITEM ==>", yeniGrupDetayi);
this.props.getSelectedGroupDetail(yeniGrupDetayi);
console.log("ACTION'DAN GELEN ITEM ===>", selectedGroupDetail);
}
Run Code Online (Sandbox Code Playgroud)
行动:
export const getSelectedGroupDetail = (yeniGrupDetayi) => {
return {
type: GET_SELECTED_GROUP_DETAIL,
payload: yeniGrupDetayi
}
};
Run Code Online (Sandbox Code Playgroud)
减速器:
case GET_SELECTED_GROUP_DETAIL:
return { ...state, selectedGroupDetail: action.payload}
Run Code Online (Sandbox Code Playgroud)
Ç?kt ?:
FONKSIYON ICERISINDEKI ITEM ==> {admin: {…}, groupDescription: "Yayg?n inanc?n tersine, Lorem Ipsum rastgele sözcü…erini inceledi?inde …Run Code Online (Sandbox Code Playgroud)