I'm writing a block of code to sort some data using React hooks. But I get the above mentions warning/error Below is my code.
const [sort, setSort] = useState(sortedInfo)
if (condition){
// some logic
} else if (columns.find((col) => col.hasOwnProperty("actualSort"))){
const {data, asc} = columns.find((col) => col.hasOwnProperty("actualSort").sorting)
setSort(data);
}
My else case gets called many times which is fine as per the condition. Anything that can be done, so that setSort calls are minimized?