Created
January 11, 2019 13:14
-
-
Save mfrachet/25ce9654dd21bc802d97f889e3ac7f23 to your computer and use it in GitHub Desktop.
react-cache-custom-fetch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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