I have two arrays, one which I am passing in as props called 'navPrimary' and the other which I am storing in state called 'dataArray'. What I am trying to do is loop through the navPrimary array and then grab the label and only add it to the 'dataArray' if it don't already exist. So far it works but will add it if it exists or not. I know I can use indexOf or filter to get what I need I just not know the syntax or wrapping technique to get it to work.
const [dataArray, setDataArray] = useState([]);
setDataArray(dataArray.concat(navPrimary.map((item) => item.label)));