I tested this a few times and I can't figure out why useState will reload, in all the tutorials and guides online, setState if the value is the same it should not cause a component re-render
My code is like this:
const [order, setOrder] = useState([]);
setOrder([500, 400, 400, 450]);
setOrder([500, 400, 400, 450]); //this causes react to rerender although the items and sequence are the same
I don't want it to re-render because each time the "order" array is changed, an API call is being made, but I only want it to call the API if the values or sequences are actually different
I tried disabling and enabling react StrictMode, and but it still rerender. I don't know why other people video it does not seem to rerender