SolidJS·SolidJS essentials

Memos and effects

createMemo derives cached values, and createEffect runs side effects.

Intermediate 10 min read Lesson 2 of 150 Challenge included
What you will be able to do
  • Use createMemo for derived state.
  • Use createEffect for side effects.
  • Dependencies are tracked automatically.

In plain English

createMemo derives cached values, and createEffect runs side effects.

  • Use createMemo for derived state.
  • Use createEffect for side effects.
  • Dependencies are tracked automatically.
Double.jsxJavaScript
import { createMemo, createSignal } from 'solid-js'

export default function Double() {
  const [count, setCount] = createSignal(1)
  const double = createMemo(() => count() * 2)
  return <p>{count()} doubled is {double()}</p>
}
Your turn

Explain it back

Easy

Answer from memory: Which primitive caches a derived value?

TEXT · starter
Your answer…
Check your understanding before moving on.
Knowledge checkQuestion 1

Which primitive caches a derived value?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Control flow
Lesson 2 of 150 · 0% of course