Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
svg is not rendering properly after update in safari

I'm working on React project and I implemented gradient generator that is used for icons. The problem is that on chrome everything works fine, but safari renders the icon normally only first time, for example, if I do some update action like change view to mobile or change state of component it turns black. When I switch between icons it regenerates until I repeat the scenario.

I read that the common problem with safari is that url path is not resolved right, but as you can see I already done that, it's not working even when the path is hardcoded. Also tried to disable canvas rendering in safari.

<svg
    width={72}
    height={26}
>
    <defs>
        <linearGradient id={object.id}>
            {this.generateStops(object.depthColors ? object.depthColors : [])}
        </linearGradient>
    </defs>
    <rect width={72} height={26} fill={`url(${window.location.href}#${object.id})`}/>
</svg>

I think I won't add more code since the problem is not with stops generation, it always returns correctly generated stops. Also I tried to add various parameters to svg like id, viewbox, but it didn't help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What I ended up doing is this:

const random = Math.random().toString();

return (
    <svg
        width={72}
        height={26}
    >
        <defs>
            <linearGradient id={random}>
                {this.generateStops(colorPalette.depthColors ? colorPalette.depthColors : [])}
            </linearGradient>
        </defs>
        <rect width={72} height={26} fill={`url(#${random})`}/>
    </svg>
);

Previous version also used unique id's for gradient generation, but it didn't refresh every time when the same gradient is selected.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!