Skip to content

Instantly share code, notes, and snippets.

@samwightt
Created July 20, 2021 18:53
Show Gist options
  • Save samwightt/e1db4e17734d604bcf3e557b1ba5823a to your computer and use it in GitHub Desktop.
Save samwightt/e1db4e17734d604bcf3e557b1ba5823a to your computer and use it in GitHub Desktop.
import currentUser from "app/auth/queries/currentUser"
// You'd need some sort of transform to evaluate this function and turn it into an object
// that could be passed to the server. You could just replace the definition of the `currentUser`
// function with:
// const currentUser = (args) => args
// and then just send the returned params to the server.
export const query = currentUser();
// This displays when the query is loading.
export const loading = () => <h1>Loading...</h1>
// This displays if the query is empty.
export const empty = () => <h1>You're not logged in :(</h1>
// This displays if there was some fetch error.
export const error = () => <h1>It looks like there was an error :(</h1>
// Finally, this shows up if the data was loaded correctly.
export const data = ({ data: currentUser }) => <h1>Hello there, {currentUser.name]!</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment