Dynamic icon name
Open
Nobody has claimed this yet.
need-repro
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 96
- Avg merge
- 8h 12m
- Merged PRs (30d)
- 2
Description
Im trying to use country-icons dynamically based on input, but Im having issues.
<script setup lang="ts">
import { Icon } from '#components'
const props = defineProps<{
country: string
}>()
const icon = computed(() => {
const icon = props?.country.toLowerCase()
if (icon == 'northern ireland') {
return 'ireland'
}
return icon
})
const FlagIcon = h(Icon, { name: 'twemoji:flag-' + icon.value, size: 18 })
</script>
<template>
<FlagIcon />
</template>
This is working when loading the page SSR, but navigating to the page results in errors like this:
DR5f3n0Z.js:52 [Icon] failed to load icon 'twemoji:flag-hungary'
How can I create the icon names dynamically?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided TypeScript script and the Nuxt Icon component, then reproduce the difference between SSR loading and client-side navigation using the dynamic twemoji:flag- name. Trace the icon loading path for navigation and verify that names such as twemoji:flag-hungary render without a client-side load error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100