I have a state variable:
const [rowValues, setRowValues] = React.useState(() => {
setAllValues(false);
});
I have attempted to initialize the default value in the Lazy Initialization Fashion
In other words, i want the default value of the state to be the return value of setAllValues(false).
Now here is the setAllValues function:
async function setAllValues(value) {
await rows.forEach((element) => {
temp = { ...temp, [element.id]: value };
});
console.log('| temp', temp);
return temp;
}
rows is a variable destructured from the props. Initial renders, the value is [], next times it renders as the expected value. Look at the image to better under-stand what im saying here:

Since the initial value of rows is [], the state gets the wrong default value. I want the function (setAllValues(false)) to run when the value of rows is [{...},{...},{...}..] , or how do i prevent rows from having the value []? Please Help.