Skip to content

Instantly share code, notes, and snippets.

@mfrachet
Created January 11, 2019 13:14
Show Gist options
  • Save mfrachet/25ce9654dd21bc802d97f889e3ac7f23 to your computer and use it in GitHub Desktop.
Save mfrachet/25ce9654dd21bc802d97f889e3ac7f23 to your computer and use it in GitHub Desktop.
react-cache-custom-fetch
export const FiberHoc = ComponentDefinition => (props = {}) => {
let vNode;
try {
vNode = ComponentDefinition(props);
} catch (e) {
vNode = props.fallback(props); // mandatory if you need to see something on the screen before your content
fetchWithCache(e.value).then(() => {
const nextNode = ComponentDefinition(props);
patch(vNode, nextNode);
});
}
return vNode;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment