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

85
Views
How to rerender {#each array} block in svelte after you push something to an array

Hello I'm making a comment section for my website which works but when I push an object to an array my {#each} block doesn't update here is this block of code

            {#each commentsScript as { userName, rating, comment }, i}
                <div class="flex">
                    <div class="w-1/4">
                        <h5>{userName}</h5>
                        <h5>{rating}</h5>
                    </div>
                    <div class="w-3/4">
                        <p>{comment}</p>
                    </div>
                </div>
            {/each}

In my script section, I push a new comment to an array and it does show up after I refresh the page but I want to rerender it as soon as the user leaves a comment so the user would see hes/her own comment so is there any way I can rerender it?

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

0

https://svelte.dev/tutorial/updating-arrays-and-objects

You have to assign commentsScript = commentsScript, which would be redundant normally, but that is how svelte works. This is true if you are using push function on array.

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!