I'm trying to display some blog post content that is sent via the API as a long HTML string. I currently have reference to a div which I update inside the onMount function by doing postContent.innerHTML = post()?.content!. However, this method feels very tacky and the screen flashes once the content is appended to the postContent div. Is there a convenience function available that I can use to accomplish this?
#Display Blog Post HTML after fetch?
21 messages · Page 1 of 1 (latest)
What is post()? A signal or a resource?
post() is this object and I'm trying to render the content field containing HTML
It comes from routeData
I mean, how are you getting that? Using createResource?
Just shared that with you
Give me a sec
Are you exporting that as routeData from your page .... and then 'useRouteData` in your component?
I'm using the solid-movies app as the base of my app
I'm using the exact same function they use inside the movie's detail page
Here's what usePost() function returns to the component
Similar to going to this page: https://solid-movies.app/movie/76600
<div innerHTML={post()...} />
Relevant code: https://github.com/solidjs/solid-start/tree/movies/examples/movies/src/routes/movie/[movieId]
Yeah, I just saw that on StackOverflow too
Let me give it a try
Not sure if post() will initially be undefined so you might need to guard that (with a default or <Show>) ...or maybe not.