i have an array of objects like this:
arr = [
{label: Alex, value: Ninja},
{label: Bill, value: Op},
{label: Cill, value: iopop}
]
This array is composed when my react component is rendered. The i user Array.prototype.unshift
for adding a desired element in the top of my array.
So i write arr.unshift({label: All, value: All})
. When my component first rendered my array is successfully created as i desire. But when i rerender it it shows me the array with the value {label: All, value: All}
as duplicate. To be more specific it is shown something like this:
arr = [
{label: All, value: All},
{label: All, value: All},
{label: Alex, value: Ninja},
{label: Bill, value: Op},
{label: Cill, value: iopop}
]
How can i fix this? I tried the methods described in a specific topic here but it didn't work