I want to use the useState
to store the value of the combined arrays. I am now getting the one
and two
array however I cannot concat both array into one. And I want to store them in a useState as well for me to map it later on a table.
const [samp, setSamp] = useState([]);
useEffect(() => {
// I am getting the values for this one.
const one = referralCodes.map((data) => {
console.log([data].join().split(","));
})
// I am getting the values for this one as well.
const two = usedReferralCodes.map((data) => {
console.log([data].join().split(","));
})
// and I want to concat both arrays and join them into one with single incrementing index value
const combined = ([...one].concat([...two]))
// this one prints
console.log("one: ", one)
// this one prints as well
console.log("two: ", two)
// this one returns undefined
console.log("combined: ", combined)
// I wanto get the combined Value and setState it so I can access it and display it on a table.
setSamp(combined);
});