I checked the implementation, but I still don’t understand.
In my head, I thought React.cache worked by doing something like this:
currentRequest = <someReference>
renderComponent() // If the function returned by React.cache is called here, then it will know the current request
currentRequest = null
But its behaviour is not very well documented and I couldn’t understand by reading the source code.
Is it correct to say that the cache function should only be called synchronously, as if calling a hook?
If it’s called asynchronously (after an await), is there a risk of it returning cached data from another request? Or is there some sort of thread-like separation, where the cache function is always guaranteed to return the current request’s cached data?