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

249
Views
Svelte: Trigger update of {#each} in child component

I am trying to update a child component with an {#each} loop inside it to add additional items by push()ing them to the array that is iterated by the child component. While an individual variable (say a string or number) works fine and array that feeds a {#each} loop doesn't seem to.

I am using a bind: to pass live data to the child component and have also tried to use a $: array statement in the child. Whatever I do, pushing new data to the array in the parent has no effect on the child, is there a way to do this or do I have to split off and re-render the whole child component {#each} loop every time?

I have posted my test script in a REPL: https://svelte.dev/repl/e1f24f8fccfa4533a1d682d163af9a66?version=3.49.0

Type text in to the input box and hit the 'Note This' button.

If you watch the JS Console you can see the array expanding, but the {#each} loop is not rendering the extra items to the child component.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Svelte works in a way where it only detects updates from assignment. You can read more about it here: https://svelte.dev/docs#component-format-script-2-assignments-are-reactive. Using methods such as push won't automatically trigger updates.

In your case you can just add testData = testData after pushing the new object and it works fine.

about 4 years ago · Santiago Trujillo 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!