I'm trying to compare two arrays, I'm receiving some values from Text components and pushing it into a new array, and while I want to compare them it's returns false even if the value of both arrays match, and this is because the first item of an array returns an empty array with values.
and this is how it looks like:
Array_1
Array_1 = [
Array [],
"Hi",
",",
"how",
"are",
"you",
"?",
]
Array_2
Array_2 = [
"Hi",
",",
"how",
"are",
"you",
"?",
]
An this is where the value goes into a new array which is Array_1
//Get selected value
const handleSelected = (e) => {
setReceivedItems(e);
};
//Update selected data at first render
useEffect(() => {
setNewItems((newItem) => [...newItem, receivedItems]);
}, [receivedItems]);
Do you think this is happen due to useState [] initial value ?