You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CommerceApiProvider passes a new object each time into the context as 'value'. Using why-did-you-render package, I have identified that each time I use useCommerceApi hook in my code to get the context, the application re-renders unnecessarily (for nearly 5 times).
It happens because of the error: 'different objects that are equal by value.'. Which means that CommerceApiProvider context value is not memoized.
Expected result
The value object that is passed to context provider should always be memoized to avoid unnecessary re-renders because of the object reference changes.
Actual result
The value object is re-created on every render, which causes all the parts of application that use the context to re-render.
Additional information
The place in code that causes the problem:
The problem representation (objects are equal by value, but different by reference):