Created
May 16, 2020 15:59
-
-
Save ryanflorence/55e272ac46205a40ae044c1dfe959c8a 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
// messages.load.js | |
export default async function() { | |
return db.read("messages") | |
} | |
// messages.js | |
import useMessagesSubscription from '../your/code' | |
import { useRouteData } from "remix" | |
function Messages() { | |
let initialMessages = useRouteData() | |
let messages = useMessagesSubscription(initialMessages) | |
return ( | |
<ul> | |
{messages.map(message => ( | |
<li>{message.content}</li> | |
))} | |
</ul> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment