I am running into an issue where I have an array with mysterious duplicates.
In firebase, my object contains the array
{
ink_colors:
0: 'Mauve',
1: 'Mineral',
2: 'Mocha',
3: 'Navy'
}
Firebase web console:
When the object is received by my React app, the console reports
console.log(snapshot.val().ink_colors);
> Array(4) [ "Mauve", "Mineral", "Mocha", "Navy" ]
BUT
when the array is accessed, it apparently has 6 items
temp1.ink_colors
// => [ "Mauve", "Mineral", "Mocha", "Navy", "Mauve", "Mauve" ]
Trying to debug this issue with a console log and debugger, I save the console output at a global variable temp1
and get two different results:
function receive(payload){
console.log(payload);
debugger;
}
> payload.ink_colors
< (4) ["Mauve", "Mineral", "Mocha", "Navy"]
> temp1.ink_colors
< (6) ["Mauve", "Mineral", "Mocha", "Navy", "Mauve", "Mauve"]
which tells me the issue is not the typical firebase array pitfall of having unexpected empty array values.
NPM Packages:
react: 16.8.2
redux: 4.0.1
firebase: 5.7.2