Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emphasize the importance of returning the value from createEffect to … #949

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion src/routes/reference/basic-reactivity/create-effect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ createEffect((prevSum) => {
// do something with `a` and `prevSum`
const sum = a() + b()
if (sum !== prevSum) console.log("sum changed to", sum)
return sum
return sum // Pay attention you must return the value that will update the previous one (prevSum)
}, 0)
// ^ the initial value of the effect is 0
```
Expand Down