[lib] Use useDerivedObject to reduce renders due to preRequestUserState
Summary:
While working on ENG-7385, I did some investigation to see why performAuth was getting regenerated. It turned out that it was largely due to preRequestUserState being regenerated.
It's hard to properly memoize this, since we need to memoize N pieces of data for each entry in an object. Neither createSelector nor useMemo can handle an unbounded list of data.
I introduced useDerivedObject in D10465 to solve precisely this problem. By integrating it here (in addition to the preceding diff) I was able to solve the issue of performAuth being cancelled during initial keyserverAuth following new user registration.
Depends on D11655
Test Plan:
- I added logs for when the performAuth got cancelled and restarted
- I ran through the new registration flow
- I confirmed that when the registration button was pressed, I no longer saw any logs about performAuth getting cancelled and restarted, and that we were no longer wasting an unnecessary amount of one-time keys
Reviewers: inka
Reviewed By: inka
Subscribers: tomek
Differential Revision: https://phab.comm.dev/D11656