Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1816

How can I define type for a component as an icon in svelte, typescript?

$
0
0

I am trying to build a navigation menu in SvelteKit.

const navigationMenu: { path: string; label: string; icon:??? }[] = [        {            path: '/',            label: 'Home',            icon: Home        },

I want to render the icon in each navigation item like this:

<ul>            {#each navigationMenu as item}<li class:active={item.path === $page.url.pathname}><a href={item.path}><svelte:component                            this={item.icon}                            focusable="false"                            aria-hidden="true"                            size={26}                            strokeWidth={2}                        />                        {item.label}</a></li>            {/each}</ul>

I could not figure out what to pass typescript type for icon

const navigationMenu: { path: string; label: string; icon:??? }[] = []

Viewing all articles
Browse latest Browse all 1816

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>