Reputation: 1135
I am using react-redux and redux-persist in my react-native project it is working fine but when i tried to add object into redux state it is throwing this error
[TypeError: undefined is not an object (evaluating 'iter[Symbol.iterator]')]
My code inside reducer is
case ADD_FILES_DURATION:
console.log("data received",action.data);
return {
...state,
filesDuration: [...state.filesDuration, action.data]
};
and my state initial values are
const initialState = {
trackSpeed: "1",
filesDuration: [],
}
and from my homescreen i am trying to insert data into redux like this
const item = {
folderName: folderName,
track: trackName,
duration: duration
}
addFileDuration(item);
it is working fine for other redux operation but whenever i am trying to run this it is giving above error
Please help if anyone knows how to resolve this or any suggestions ?
Upvotes: 5
Views: 14368
Reputation: 101
I had the same error on my simulator when using react-native. The error info is like this:
TypeError: null is not an object (evaluating 'iter[Symbol.iterator]')
Because I setValue as null, but expected as Array.
Upvotes: 2
Reputation: 43
This error made no sense to me as I was using another reducer with the same logic, turns out all you have to do is restart your project (I also deleted the app from my simulator)
Upvotes: 2
Reputation: 1135
After work around , i found what i was doing wrong
i was wrongly inserting data into redux that's the reason i was getting this error
So instead of this
const item = {
folderName: folderName,
track: trackName,
duration: duration
}
addFileDuration(item);
i used this
const item = {
"folderName": folderName,
"track": trackName,
"duration": duration
}
addFileDuration(item);
now it is working fine hope it may help anybody
Upvotes: 2