每当我尝试使用post方法将对象推入数组时,都会显示此警告
这是在带有Redux的React-Native中发生的,我在后端使用了Firebase。
Exception was thrown by user callback. TypeError: Cannot add property 0, object is not extensible
at Array.push (<anonymous>)
at blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:104234:59
at blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:90326:24
at LLRBNode.inorderTraversal (blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:89149:58)
at SortedMap.inorderTraversal (blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:89453:31)
at ChildrenNode.forEachChild (blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:89926:39)
at DataSnapshot.forEach (blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:90325:35)
at blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:104233:35
at onceCallback (blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:90716:55)
at blob:file:///d0f11e65-c690-4662-8ef6-91001f662c11:90450:26
错误是
ExceptionsManager.js:63 Cannot add property 0, object is not extensible
代码
authLoggedInUserKey = userKey;
let requestedUser = [];
//This code get data form the user to whom loggedin user send request
let userDetail = userRef.child(authLoggedInUserKey).child('requestedUserData');
userDetail.once('value',(snap) =>{
snap.forEach((child) => {
let requestedUserKey = child.val().requestedUser;
let requestedUserDetail = userRef.orderByKey().equalTo(requestedUserKey);
requestedUserDetail.once('value',(snap1)=>{
snap1.forEach((child1) => {
requestedUser.push({ //Error generated here
firstName: child1.val().firstName,
})
})
})
})