Re:Beyond React 16 by Dan Ambramov – Async Rendering and Rea...
by btown on Thursday March 01, 2018 @03:18PM
(#16495824)
It seems from https://github.com/facebook/react/blob/master/packages/simpl... that in the live version you'll be specifying which cache to use; this could be global, provided via React's old or new Context APIs, or passed down through props. And you could always write your own fetcher factory if you want to do something really custom; there's nothing special about the SimpleCacheProvider, and it doesn't use any React internals.
[ Parent
| on HN ]
Re:Beyond React 16 by Dan Ambramov – Async Rendering and Rea...
by danabramov on Thursday March 01, 2018 @03:45PM
(#16496133)
FWIW my demo code looked like
export let cache;
function initCache() {
cache = createCache(initCache);
}
initCache();
export function createFetcher(fetch) {
const res = createResource(fetch);
return {
read(...args) {
return res(cache, ...args);
},
};
}