There are some architectural issues with our current <AccessType> component which I'm noting here: These issues made working with the component hard:
- on
componentDidMount we're calling initAccessType which makes the subsequent calls like this.getSubscription() and this.getPaymentOptions() always happening if somehow the component is re-mounted. This is not needed as we should let the users of the component decide when to call initAccessType as we're exposing it through renderProp anyway. The component calling itself counter the full renderProp idea.
Note: when removing make sure the users of <AccessType> are calling initAccessType explicitly when needed.
- API calls like
this.getPaymentOptions() should be cached in memory.
- There should be more exposed helper functions like
setUser and getJWTToken and try to memoize the results.
There are some architectural issues with our current
<AccessType>component which I'm noting here: These issues made working with the component hard:componentDidMountwe're callinginitAccessTypewhich makes the subsequent calls likethis.getSubscription()andthis.getPaymentOptions()always happening if somehow the component is re-mounted. This is not needed as we should let the users of the component decide when to callinitAccessTypeas we're exposing it through renderProp anyway. The component calling itself counter the full renderProp idea.Note: when removing make sure the users of
<AccessType>are callinginitAccessTypeexplicitly when needed.this.getPaymentOptions()should be cached in memory.setUserandgetJWTTokenand try to memoize the results.