-
-
Save mweststrate/439e6ea8770a843c317df1ccb7ed11fe to your computer and use it in GitHub Desktop.
This file contains 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
const Document = observer(({ view, store }) => { | |
if (!store.isAuthenticated) | |
return <Login store={store} afterLogin={() => store.showDocument(view.documentId)} /> | |
switch (view.document.state) { | |
case "pending": | |
return <h1>Loading document.. { view.documentId }</h1> | |
case "rejected": | |
return <Error error={view.document.reason} /> | |
case "fulfilled": | |
return ( | |
<div> | |
<button onClick={() => store.showOverview()}>Overview</button> | |
<h1>{ view.document.value.name }</h1> | |
<p> { view.document.value.text }</p> | |
</div> | |
) | |
} | |
}) | |
const Error = ({ error }) => <h1>{"Error: " + error}</h1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment