Git Product home page Git Product logo

Comments (6)

cyberalien avatar cyberalien commented on May 29, 2024

Its probably something else in your code. Error message is clear: missing </span> element. Neither Iconify library renders span elements.

from iconify.

nghiepdev avatar nghiepdev commented on May 29, 2024

That is because the client site transform to <svg> tag. does not match <span> tag on server.

from iconify.

cyberalien avatar cyberalien commented on May 29, 2024

Yes, that's normal behaviour for this library. However @iconify/react generates SVG, so you can use that instead.

from iconify.

nghiepdev avatar nghiepdev commented on May 29, 2024

Thanks @cyberalien
But @iconify/react what way to render only on the client? Example

<Icon icon={faceWithMonocle} ssr={false} />

Because If uses many svg icon thenPageSpeed Insights warning DOM elements.

from iconify.

cyberalien avatar cyberalien commented on May 29, 2024

Looks like Next.js is making rendering on client impossible.

You can try this: use @iconify/iconify, but instead of adding span, wrap it in some other element and use dangerouslySetInnerHTML to insert span:

function Icon(props) {
  const html = '<span class="iconify" data-icon="' + props.icon + '"></span>';
 return <span dangerouslySetInnerHTML={{__html: html}} />;
}

Not sure if it will work, but it might. This way it will have 2 span elements, Next.js should only watch for one that Iconify won't modify and inner one will be changed to svg by Iconify.

from iconify.

nghiepdev avatar nghiepdev commented on May 29, 2024

@cyberalien thanks, might react-no-ssr would be help me.

from iconify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.