solid-refresh icon indicating copy to clipboard operation
solid-refresh copied to clipboard

components created unnecessarily

Open derekrjones opened this issue 4 months ago • 1 comments

in the following example, when refreshed, CompB is created more times than it should

// ex. App.tsx has single <CompA/>
export const function CompA() {
  console.log('A');
  return <CompB />;
}
function CompB() {
  console.log('B');
  return <div>hi</div>;
}

initial run logs A B file save, logs B A B (or A B B if CompB initially placed above CompA)

If CompB was costly, then this would have an impact of perf.

derekrjones avatar Oct 04 '25 07:10 derekrjones

Would using batch() in patchRegistry be a solution? (batch patchContexts and patchComponents)

https://github.com/solidjs/solid-refresh/blob/e5b99c2f525ad0e5922c6d5c79e93c40c0b64f50/src/runtime/index.ts#L171-L179

derekrjones avatar Oct 04 '25 07:10 derekrjones