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

88
Views
Nested createEffect doesn't refire

I am not sure, if I have correctly reproduced my problem but here it is:

On render signal, I have some sort of object creation that leads to more create effects that depend on update signal. But somehow the scope gets disposed and it only fires once at creation time. Even though I have references to these objects, how can I make sure nested createEffect keeps firing?

import { render } from 'solid-js/web';
import { on, createSignal, createEffect } from 'solid-js'

function HelloWorld() {

  let [render, setRender] = createSignal(undefined, { equals: false })

  let [update, setUpdate] = createSignal(undefined, { equals: false })
let i = 0

  createEffect(on(render, () => {
    if (i++ === 1) {
      createEffect(on(update, () => {
        console.log('inside')
      }))
    }
  }))

  createEffect(on(update, () => {
    console.log('regular', i)
  }))

 setInterval(() => {
   setUpdate();
    setRender();
  })
  return <div>Hello World!</div>;
}

render(() => <HelloWorld />, document.getElementById('app'))

I want regular and inside logs on every interval.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use createRoot to overwrite the root of the nested createEffect. Otherwise it will be disposed on each rerun of the "parent" effect.

createEffect(() => {
   createRoot(dispose => {
      // effect will be disposed only when
      // the dispose() fn get's called
      createEffect(() => {...})
   })
})

https://playground.solidjs.com/?hash=-999371052&version=1.3.13

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!