Replies: 2 comments 5 replies
-
I think the server doesn't render anything because the promise does not resolve. Currently you have states for when it resolves or errors out:
But not while awaiting:
|
Beta Was this translation helpful? Give feedback.
4 replies
-
Why not do your thing this way: <script>
export let icon, width = '1em', style = ''
let icons = {
'shopping-cart': '<path fill="currentColor" d="M4 16V4H2V2h3a1 1 0 0 1 1 1v12h12.438l2-8H8V5h13.72a1 1 0 0 1 .97 1.243l-2.5 10a1 1 0 0 1-.97.757H5a1 1 0 0 1-1-1zm2 7a2 2 0 1 1 0-4a2 2 0 0 1 0 4zm12 0a2 2 0 1 1 0-4a2 2 0 0 1 0 4z"></path>',
'search-2': '<path fill="currentColor" d="M11 2c4.968 0 9 4.032 9 9s-4.032 9-9 9s-9-4.032-9-9s4.032-9 9-9zm0 16c3.867 0 7-3.133 7-7c0-3.868-3.133-7-7-7c-3.868 0-7 3.132-7 7c0 3.867 3.132 7 7 7zm8.485.071l2.829 2.828l-1.415 1.415l-2.828-2.829l1.414-1.414z"></path>',
'arrow-left': '<path fill="currentColor" d="M7.828 11H20v2H7.828l5.364 5.364l-1.414 1.414L4 12l7.778-7.778l1.414 1.414z"></path>',
'blaze': '<path fill="currentColor" d="M19 9c.667 1.06 1 2.394 1 4c0 3-3.5 4-5 9c-.667-.575-1-1.408-1-2.5c0-3.482 5-5.29 5-10.5zm-4.5-4a8.31 8.31 0 0 1 1 4c0 5-6 6-4 13C9.833 20.84 9 19.173 9 17c0-3.325 5.5-6 5.5-12zM10 1c.667 1.333 1 2.833 1 4.5c0 6-9 7.5-3 16.5c-2.5-.5-4.5-3-4.5-6C3.5 9.5 10 8.5 10 1z"></path>',
'home-3': '<path fill="currentColor" d="M19 21H5a1 1 0 0 1-1-1v-9H1l10.327-9.388a1 1 0 0 1 1.346 0L23 11h-3v9a1 1 0 0 1-1 1zM6 19h12V9.157l-6-5.454l-6 5.454V19zm2-4h8v2H8v-2z"></path>',
}
</script>
<svg width="{width}" height="{width}" {style} viewBox="0 0 24 24">
{@html icons[icon]}
</svg> This works in SSR and is more managable. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following component
icon.svelte
which dynamically imports the correct icon component and renders it:This works fine on the client side. On the server however the component is not awaited and therefore nothing is rendered.
Is there a way to make the server wait until the
#await
has resolved?Beta Was this translation helpful? Give feedback.
All reactions