If rest contains dynamic objects, but changes are rare, you can use a useRef to store the last value and detect changes manually:
You can also use lodash for deep and equal comparison