This long-awaited release significantly changes how the reactive system works. This should solve several correctness issues/rough edges that related to the manual use of cx
/Scope
and could create memory leaks. (See #918 for details)
It also has the fairly large DX change (improvement?) of removing the need to pass cx
or Scope
variables around at all.
Migration is fairly easy. 95% of apps will migrate completely by making the following string replacements:
cx: Scope,
=> (empty string)cx: Scope
=> (empty string)cx,
=> (empty string)(cx)
=>()
|cx|
=>||
Scope,
=> (empty string)Scope
=> (empty string) as needed- You may have some
|_, _|
that become|_|
or|_|
that become||
, particularly for thefallback
props on<Show/>
and<ErrorBoundary/>
Basically, there is no longer a Scope
type, and anything that used to take it can simply be deleted.
For the 5%: if you were doing tricky things like storing a Scope
somewhere in a struct or variable and then reusing it, you should be able to achieve the same result by storing Owner::current()
somewhere and then later using it in with_owner(owner, move || { /* ... */ })
.
There are no other big conceptual or API changes in this update: essentially all the same reactive, templating, and component concepts should still apply, just without cx
.
Expected to Not Work
leptosfmt
and cargo leptos --hot-reload
, which assume that the view!
needs a cx,
, will probably not work as intended and will need to be updated.
Any other ecosystem libraries that depend on Leptos 0.4 won't work, of course.
Help Wanted
This needs pretty extensive testing with real apps. It passes our test suite and the examples seem to work fine, but I'm sure there are bugs out there. Help find them! I've created a discussion linked to these release notes that you can use for feedback or to help track down bugs.