nuxt / nuxt/icon

Empty SVG tags when using renderToString() for the first time

Open
#255 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
TypeScript
Stars
1.2k
Forks
96
Avg merge
8h 12m
Merged PRs (30d)
2

Description

I render a component including icons (with mode svg) to html code to be shown in eBay descriptions:

import { renderToString } from '@vue/server-renderer';
import { MyComponent } from '#components';

onMounted(async () => {
  await renderToString(
    h(MyComponent, {
      prop1: 'hello',
    }),
  );
})

Since I updated to 1.4.x the icons are not working anymore. The svg tags are just empty.

I tried out a lot and found out that the svg tags are just empty on first call of renderToString(). But they are visible when one of this conditions is true:

  • When changing something on the page and Nuxt is refreshing (without refreshing the browser window)
  • If I call it twice with a little delay between the icons are working correctly
  • If I have the same icon visible on the page already

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the first-call behavior around the renderToString() entry point described in the issue, comparing it with a delayed second call and an icon already visible on the page. Done means the initial renderToString() call produces populated SVG tags for the component's icons, with the existing reproduction conditions covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.