Releases: leptos-rs/leptos
v0.5.0-rc2
What's Changed
- build(examples): make it easier to run examples by @agilarity in #1697
- fix: a few small fixes to rc1 by @gbj in #1704
- fix: impl
IntoView
forRc<dyn Fn() -> impl IntoView>
by @Baptistemontan in #1698 - feat: impl
From<HtmlElement<El>> for HtmlElement<AnyElement>
by @jquesada2016 in #1700 - doc(examples): reference run instructions by @agilarity in #1705
- feat: Callbacks: Manual Clone and Debug impl; Visibility fix by @lpotthast in #1703
- feat: impled LeptosRoutes for &mut ServiceConfig in integrations/actix by @cosmobrain0 in #1706
- docs: update possibly deprecated docs for
component
macro by @ChristopherPerry6060 in #1696 - fix: exclude markdown files from examples lists by @agilarity in #1716
- fix(examples/build): do not require stop to end trunk by @agilarity in #1713
- docs: fix a typo that prevented the latest appendix from appearing in the book by @g2p in #1719
- feat: support
move
onwith!
macros by @blorbb in #1717 - feat: implement
Serialize
andDeserialize
forOco<_>
by @gbj in #1720 - fix: document
#[prop(default = ...)]
as in Optional Props (closes #1710) by @gbj in #1721 - fix: correctly register
Resource::with()
(closes #1711) by @gbj in #1726 - fix: replace uses of
create_effect
internally withcreate_isomorphic_effect
(closes #1709) by @gbj in #1723 - fix: relax bounds on
LeptosRoutes
by @ChristopherPerry6060 in #1729 - feat: Allow component names to be paths by @mrvillage in #1725
- feat: use
attr:
syntax rather thanAdditionalAttributes
by @gbj in #1728
New Contributors
- @cosmobrain0 made their first contribution in #1706
- @g2p made their first contribution in #1719
Full Changelog: v0.5.0-rc1...v0.5.0-rc2
v0.5.0-rc1
I'm planning on releasing 0.5.0 proper toward the end of this week. However, we've continued having some really good new features and some changes, so I want to give it some additional time for testing rather than rushing and breaking things.
For overall 0.5.0 changes, see here.
New Features in this Release
attr:
on components, and spreading attributes
Makes it much easier to pass some set of attributes to be given to a component (with attr:
passed into a #[prop(attrs)]
prop), and then to spread them onto an element with {..attrs}
syntax.
#[component]
pub fn App() -> impl IntoView {
view! {
<Input attr:value="hello" attr:label="foo" />
<Input attr:type="number" attr:value="0" />
}
}
#[component]
pub fn Input(
#[prop(attrs)] attrs: Vec<(&'static str, Attribute)>,
) -> impl IntoView {
view! {
<input {..attrs} />
<pre>{format!("{attrs2:#?}")}</pre>
}
}
Generics on components in view
Newly added support for syntax that identifies a generic type for a component in the view
#[component]
pub fn GenericComponent<S>(#[prop(optional)] ty: PhantomData<S>) -> impl IntoView {
std::any::type_name::<S>()
}
#[component]
pub fn App() -> impl IntoView {
view! {
<GenericComponent<String>/>
<GenericComponent<usize>/>
<GenericComponent<i32>/>
}
}
Callback
types
These make it easier to add things like optional callback functions to components.
#[component]
pub fn App() -> impl IntoView {
view! {
<ShowOptFall when=|| { 5 < 3 } fallback=|_| view! { <p>"YES"</p> }>
<p>"NO"</p>
</ShowOptFall>
<ShowOptFall when=|| { 5 < 3 }>
<p>"NO"</p>
</ShowOptFall>
<ShowOptFall when=||{ 5 > 3 }>
<p>"YES"</p>
</ShowOptFall>
}
}
#[component]
pub fn ShowOptFall<W>(
/// The components Show wraps
children: Box<dyn Fn() -> Fragment>,
/// A closure that returns a bool that determines whether this thing runs
when: W,
/// A closure that returns what gets rendered if the when statement is false
#[prop(optional, into)]
fallback: Option<ViewCallback<()>>,
) -> impl IntoView
where
W: Fn() -> bool + 'static,
{
let memoized_when = create_memo(move |_| when());
move || match memoized_when.get() {
true => children().into_view(),
false => match fallback.as_ref() {
Some(fallback) => fallback.call(()).into_view(),
None => ().into_view(),
},
}
}
with!()
and update!()
macros
Nested .withI()
calls are a pain. Now you can do
let (first, _) = create_signal("Bob".to_string());
let (middle, _) = create_signal("J.".to_string());
let (last, _) = create_signal("Smith".to_string());
let name = move || with!(|first, middle, last| format!("{first} {middle} {last}"));
instead of
let name = move || {
first.with(|first| {
middle.with(|middle| last.with(|last| format!("{first} {middle} {last}")))
})
};
Rustier interfaces for signal types
This framework's origins as a Rust port of SolidJS mean we've inherited some functional-JS-isms. Combined with the need to pass cx
everywhere prior to 0.5 this has tended to mean we've gone with create_
and so on rather than Rusty ::new()
. This simply adds a few Rustier constructors like
let count = RwSignal::new(0);
let double_count = Memo::new(move |_| count() * 2);
Breaking Changes
- Renaming
.derived_signal()
and.mapped_signal_setter()
to the more idiomatic.into_signal()
and.into_signal_setter()
- Memoizing whether
Suspense
is ready yet or not in order to avoid over-re-rendering. Shouldn't break your app, but if something weird happens let me know. - Changes timing of
create_effect
so that it runs a tick after it is created, which solves a number of timing issues with effects that had previously led tocreate_effect(move || request_animation_frame(move || /* */))
What's Changed
- doc(examples): add fantoccini to test-runner-report (#1615) by @agilarity in #1616
- docs: Derived signals - Clarified derived signals by @martinfrances107 in #1614
- doc(book,deployment): update reference to binary in dockerfile by @SadraMoh in #1617
- docs: fix typo by @dpytaylo in #1618
- docs: remove extra space by @Lawqup in #1622
- docs(book): fix wrong variable name by @Gaareth in #1623
- feat: Callback proposal by @rambip in #1596
- Configuration for Hot-Reloading Websocket Protocol and enable ENV PROD selection by @Indrazar in #1613
- feat: implement simple spread attributes by @mrvillage in #1619
- fix: memoize Suspense readiness to avoid rerendering children/fallback by @gbj in #1642
- feat: add component generics by @mrvillage in #1636
- hide
get_property
by @jquesada2016 in #1638 - Into thing boxed by @jquesada2016 in #1639
- docs: cleanup by @Banzobotic in #1626
- fix: versioned resources never decrement Suspense (closes #1640) by @gbj in #1641
- Rename into signal traits by @jquesada2016 in #1637
- feat: start adding some Rustier interfaces for reactive types by @gbj in #1579
- test(error_boundary): add e2e testing by @agilarity in #1651
- fix: custom events on components by @liquidnya in #1648
- fix: compare path components to detect active link in router by @flo-at in #1656
- Tailwind example update by @SleeplessOne1917 in #1625
- refactor(examples): extract client process tasks (#1665) by @agilarity in #1666
- change: move logging macros into a
logging
module to avoid name conflicts withlog
andtracing
by @gbj in #1658 - Router version bump by @martinfrances107 in #1673
- Chore: Bump to actions/checkout@v4 by @martinfrances107 in #1672
Rc
backedChildrenFn
by @Baptistemontan in #1669- Remove (most) syn 1 dependencies by @blorbb in #1670
- chore: Removed resolver link warning. by @martinfrances107 in #1677
- examples: add note about potential for memory leaks with nested signals by @gbj in #1675
- feat: islands by @gbj in #1660
- Docs: a bunch of small improvements by @gbj in #1681
- Chore: Remove ambiguity surrounding version numbers. by @martinfrances107 in #1685
- fix: restore deleted
extract_with_state
function by @gbj in #1683 - fix: broken
mount_to_body
in CSR mode by @gbj in #1688 - Chore: cleared "cargo doc" issue. by @martinfrances107 in #1687
- Update interlude_projecting_children.md by @mjarvis9541 in #1690
- feat: Add dynamically resolved attributes by @mrvillage in #1628
- docs: add docs for
#[island]
macro by @gbj in #1691 - change: run effects after a tick by @gbj in #1680
- feat: with! macros by @blorbb in #1693
New Contributors
- @mrnossiom made their first contribution in #1532
- @lker-dev made their first contribution in #1557
- @Senzaki made their first contribution in #1564
- @flisky made their first contribution in #1571
- @rkuklik made their first contribution in #1444
- @rabidpug made their first contribution in #1548
- @Maneren made their first contribution in #1612
- @drdo made their first contribution in #1597
- @JonRCahill made their first contribution in #1604
- @realeinherjar made their first contribution in #1610
- @SadraMoh made their first contribution in #1617
- @dpytaylo made their first contribution in #1618
- @Lawqup made their first contribution in #1622
- @Gaareth made their first contribution in #1623
- @rambip made their first contribution in #1596
- @mrvillage made their first contribution in #1619
- @Banzobotic m...
v0.5.0-beta2
Just another beta release. I'm expecting to release 0.5.0 itself in the next couple weeks, there have just been a couple other small but breaking changes proposed that are working their way through, and I'd rather delay a bit than rush it and be stuck.
0.5.0-beta2
reflects the current state of the main
branch. The v0.5.0
in General section is copied and pasted from previous releases. New this Release reflects changes since 0.5.0-beta
(I think?).
New this Release
- Make all arguments to
#[server]
optional: change default prefix to/api
and default to generating aPascalCase
type name from the function name
// before
#[server(MyName, "/api")]
pub async fn my_name() /* ... */
// after
#[server]
pub async fn my_name /* ... */
create_effect
now returns anEffect
struct. This exists mostly so you can.dispose()
it early if you need. (This may require adding some missing semicolons, ascreate_effect
no longer returns()
.)- Support passing signals directly as attributes, classes, styles, and props on stable
- Signal traits now take an associated
Value
type rather than a generic (see #1578) - Many APIs that previously took
impl Into<Cow<'static, str>>
now takeimpl Into<Oco<'static, str>>
.Oco
(Owned Clones Once) is a new type designed to minimized the cost of cloning immutable string types, like the ones used in theView
. Essentially this makes it cheaper to clone text nodes and attribute nodes within the renderer, without imposing an additional cost when you don't need to. This shouldn't require changes to your application in most cases of normal usage. (See #1480 for additional discussion.)
v0.5.0
in General
Reactive System Changes
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
.
What's Changed
- change: shift from
Scope
-based ownership to reactive ownership by @gbj in #918 - refactor(workflows): extract calls by @agilarity in #1566
- refactor(verify-changed-examples): improve readability and runtime by @agilarity in #1556
- Remove Clone requirement for slots in Vec by @Senzaki in #1564
- fix: INFO is too high a level for this prop tracing by @gbj in #1570
- fix: suppress warning about non-reactivity when calling
.refetch()
(occurs in e.g., async blocks in actions) by @gbj in #1576 - fix: nightly warning in server macro for lifetime by @markcatley in #1580
- fix: runtime disposal time in
render_to_string_async
by @gbj in #1574 - feat: support passing signals directly as attributes, classes, styles, and props on stable by @gbj in #1577
- feat: make struct name and path optional for server functions by @gbj in #1573
- support effect dispose by @flisky in #1571
- fix(counters_stable): restore wasm tests (#1581) by @agilarity in #1582
- fix: fourth argument to server functions by @gbj in #1585
- feat: signal traits should take associated types instead of generics by @gbj in #1578
- refactor(check-stable): use matrix (#1543) by @agilarity in #1583
- feat: add
Fn
traits for resources on nightly by @gbj in #1587 - Convenient event handling with slots by @rkuklik in #1444
- fix: correct logic for resource loading signal when read outside suspense (closes #1457) by @gbj in #1586
- Update autoreload websocket connection to work outside of localhost by @rabidpug in #1548
- Some resource and transition fixes by @gbj in #1588
- fix: broken test with untrack in tracing props by @gbj in #1593
- feat: update to
typed-builder
0.16 (closes #1455) by @gbj in #1590 Oco
(Owned Clones Once) smart pointer by @DanikVitek in #1480- docs: add docs for builder syntax by @gbj in #1603
- chore(examples): improve cucumber support #1598 by @agilarity in #1599
- fix(ci): add new webkit dependency (#1607) by @agilarity in #1608
- fix(macro/params): clippy warning by @Maneren in #1612
- Improve server function client side error handling by @drdo in #1597
- Don't try to parse as JSON the result from a server function redirect by @JonRCahill in #1604
- fix: add docs on #[server] functions by @realeinherjar in #1610
New Contributors
- @Senzaki made their first contribution in #1564
- @flisky made their first contribution in #1571
- @rkuklik made their first contribution in #1444
- @rabidpug made their first contribution in #1548
- @Maneren made their first contribution in #1612
- @drdo made their first contribution in #1597
- @JonRCahill made their first contribution in #1604
- @realeinherjar made their first contribution in #1610
Full Changelog: v0.4.9...0.5.0-beta2
v0.4.9
I'm getting ready to merge the effect-cleanups
branch into main, as well as merging #1480 and #1485 in preparation for the release of 0.5.0, so this release is just a "final state of 0.4.x" release before the main branch switches over from being 0.4 to 0.5. It does include some notable work, though:
- refactored
view
macro with snapshot testing - improved hydration performance, avoiding browser work by reusing existing text nodes in certain cases
- including component props in
tracing
support - many small bugfixes and improvements to docs
What's Changed
- fix: js scoping by @mateusvmv in #1489
- refactor: refactor + snapshot tests by @vldm and @gbj in #1435
- fix: github links by @markcatley in #1493
- docs: typo: nightly is with a t by @stappersg in #1497
- perf: in hydration, reuse existing text node by @gbj in #1506
- fix: rkyv
copy
feature is now only enabled if nightly feature is enabled by @thestarmaker in #1503 - test(todo_app_sqlite): add e2e tests (#1448) by @agilarity in #1467
- fix: render empty dynamic text node in HTML as
- fix behavior of
create_query_signal
by @DanikVitek in #1508 - fix(suspense-tests): build errors (#1517) by @agilarity in #1518
- test(todo_app_sqlite_axum): add e2e tests (#1514) by @agilarity in #1515
- docs: additional random docs by @gbj in #1523
- docs: add
use_navigate
to router docs in guide by @gbj in #1524 - docs: typos in
NavigateOptions
docs by @gbj in #1525 - docs: expand on the need for
prop:value
by @gbj in #1526 - docs: advanced docs on reactive graph, and update testing docs by @gbj in #1529
- docs: give a compile error when trying to put a child inside a self-closing HTML tag (closes #1535) by @gbj in #1537
- chore: fixed lint warning seen while running
cargo doc
by @martinfrances107 in #1539 - examples: on_cleanup misorder? in fetch examples by @mrnossiom in #1532
- test(suspense-tests): add e2e tests (Closes #1519) by @agilarity in #1533
- chore(test_examples): remove obsolete directory by @agilarity in #1540
- perf(check-stable): only run workflow on leptos source change (#1541) by @agilarity in #1542
- docs: documentation update for by @lker-dev in #1557
- docs: tell where the source is by @stappersg in #1498
- feat: tracing component property by @luoxiaozero in #1531
- build(docs): only publish on new version tags by @gbj in #1562
New Contributors
- @mateusvmv made their first contribution in #1489
- @stappersg made their first contribution in #1497
- @mrnossiom made their first contribution in #1532
- @lker-dev made their first contribution in #1557
Full Changelog: v0.4.8...v0.4.9
v0.5.0-beta
This beta release brings us closer to 0.5.0 proper.
The big changes are dropping cx/Scope
entirely. I've copied and pasted the 0.5.0-alpha release notes below for reference, along with a few notes about other changes since the alpha release. A few other changes (#1480, #1485) will be incorporated once it's ready for release.
v0.5.0
in General
Reactive System Changes
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
.
Other New Features
Now that we don't need an extra Scope
argument to construct them, many of the signal types now implement Serialize
/Deserialize
directly, as well as From<T>
. This should make it significantly easier to do things like "reactively serialize a nested data structure in a create_effect
" — this removed literally dozens of lines of serialization/deserialization logic and a custom DTO from the todomvc
example. Serializing a signal simply serializes its value, in a reactive way; deserializing into a signal creates a new signal containing that deserialized value.
Other Changes
use_navigate
navigate function no longer returns a value
The navigate("path", options)
call now uses request_animation_frame
internally to delay a tick before navigating, which solves a few odd edge cases having to do with redirecting immediately and the timing of reactive system cleanups. This was a change that arose during 0.3 and 0.4 and is being made now to coincide with other breaking changes and a new version.
If you were relying on the Result<_, _>
here and want access to it, let me know and we can bring back a version that has it. Otherwise, this shouldn't really require any changes to your app.
window_event_listener
and friends now return a handle for removal
This one was just an API oversight originally, again taking advantage of the semver update. window_event_listener
and its untyped version now return a WindowListenerHandle
with a .remove()
method that can be called explicitly to remove that event, for example in an on_cleanup
.
Again, shouldn't require meaningful changes.
#[component]
fn TypingPage() -> impl IntoView {
let handle = window_event_listener(ev::keypress, |ev| {
/* do something */
});
on_cleanup(move || handle.remove());
}
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.
v0.4.8
There was a log erroneously left in 0.4.7, so I rereleased as 0.4.8. Notes for 0.4.7 below.
This is mostly a bug-fix release with a few small features. There will probably be one or two more patch releases before 0.5.0
.
New Features
mut
in component props
This didn't work before; now it does:
#[component]
fn TestMutCallback<'a, F>(
cx: Scope,
mut callback: F,
value: &'a str,
) -> impl IntoView
where
F: FnMut(u32) + 'static,
{
MaybeProp
type
MaybeProp
is essentially a wrapper for Option<MaybeSignal<Option<T>>>
with a nicer API. This is useful for something like a component library, where you want to give a user the maximum flexibility in the types they give to props while still checking that they're the appropriate T
.
This allows you to define optional props that
- may or may not be provided
- if provided, may be a plain value or a signal
- if a signal type, may or may not have a value (i.e., are a
Signal<Option<T>>
)
Implementing
From<_>
for a plainSignal<T>
type here is possible, but depends on the changes in0.5.0
, so I'll add it for that release.
#[component]
pub fn App(cx: Scope) -> impl IntoView {
let (count, set_count) = create_signal(cx, 5);
view! { cx,
<TakesMaybeProp/>
<TakesMaybeProp maybe=42/>
<TakesMaybeProp maybe=Signal::derive(cx, move || Some(count.get()))/>
}
}
#[component]
pub fn TakesMaybeProp(cx: Scope, #[prop(optional, into)] maybe: MaybeProp<i32>) -> impl IntoView {
// .get() gives you `Option<T>`, replacing `self.as_ref().and_then(|n| n.get())`
let value: Option<i32> = maybe.get();
// .with() takes a plain `&T`; returns `None` if the prop isn't present or the inner value is None
let plus_one = maybe.with(|n: &i32| n + 1);
view! { cx,
<p>{maybe}</p>
}
}
v0.4.7
This is mostly a bug-fix release with a few small features. There will probably be one or two more patch releases before 0.5.0
.
New Features
mut
in component props
This didn't work before; now it does:
#[component]
fn TestMutCallback<'a, F>(
cx: Scope,
mut callback: F,
value: &'a str,
) -> impl IntoView
where
F: FnMut(u32) + 'static,
{
MaybeProp
type
MaybeProp
is essentially a wrapper for Option<MaybeSignal<Option<T>>>
with a nicer API. This is useful for something like a component library, where you want to give a user the maximum flexibility in the types they give to props while still checking that they're the appropriate T
.
This allows you to define optional props that
- may or may not be provided
- if provided, may be a plain value or a signal
- if a signal type, may or may not have a value (i.e., are a
Signal<Option<T>>
)
Implementing
From<_>
for a plainSignal<T>
type here is possible, but depends on the changes in0.5.0
, so I'll add it for that release.
#[component]
pub fn App(cx: Scope) -> impl IntoView {
let (count, set_count) = create_signal(cx, 5);
view! { cx,
<TakesMaybeProp/>
<TakesMaybeProp maybe=42/>
<TakesMaybeProp maybe=Signal::derive(cx, move || Some(count.get()))/>
}
}
#[component]
pub fn TakesMaybeProp(cx: Scope, #[prop(optional, into)] maybe: MaybeProp<i32>) -> impl IntoView {
// .get() gives you `Option<T>`, replacing `self.as_ref().and_then(|n| n.get())`
let value: Option<i32> = maybe.get();
// .with() takes a plain `&T`; returns `None` if the prop isn't present or the inner value is None
let plus_one = maybe.with(|n: &i32| n + 1);
view! { cx,
<p>{maybe}</p>
}
}
What's Changed
- (doc)expand spawn_local documentation by @Bechma in #1433
- fix(examples): unable to parse makefile (#1440) by @agilarity in #1441
- fix: incorrect opening node for
<Each/>
in debug mode (closes #1168) by @gbj in #1436 - docs: fix typo in 23_ssr_modes.md by @gbj in #1445
- feat: add
MaybeProp
type by @gbj in #1443 - perf(examples): speed up the test-info report (#1446) by @agilarity in #1447
- feat: allow
mut
in component props and suppress "needless lifetime" warning (closes #1458) by @gbj in #1459 - fix:
AnimatedShow
- possible panic on cleanup by @sebadob in #1464 - Document the magic number 128 as FILTER_SHOW_COMMENT. by @martinfrances107 in #1468
- Update README.md by @randommm in #1470
- fix: properly replace text nodes in DynChild (closes #1456) by @gbj in #1472
- fix: compile-time regression for deeply-nested component trees by @gbj in #1476
- fix: correctly escape HTML in DynChild text nodes by @gbj in #1478
- Minor: doclink to Error needed FQDN. by @martinfrances107 in #1469
- Fix typo in docs for
ServerFnErrorErr
by @DanikVitek in #1477 - fix: correctly export all DOM helpers by @gbj in #1486
New Contributors
- @Bechma made their first contribution in #1433
- @randommm made their first contribution in #1470
- @DanikVitek made their first contribution in #1477
Full Changelog: v0.4.6...v.0.4.7
v0.5.0-alpha
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.
v0.4.6
Features
- Improved support for a wider set of valid HTML attribute names (like
class:something-500
) not previously supported (@vldm in #1416) - Get and set individual URL search/query params with
create_query_signal
(@tqwewe in #1377) - feat: create an
<AnimatedShow>
component (closes #1370) (@sebadob in #1386) - feat: implement
Resource::dispose()
by @gbj in #1393
Miscellaneous
- Doc proof-reading by @aperepel in #1380
- refactor: remove unnecessary string allocation in
TryFrom
forUrl
by @tqwewe in #1376 - docs: small issues by @gbj in #1385
- docs: correct docs for
create_memo
to reflect laziness by @gbj in #1388 - Minor: Removed call to .into(), plus minor touch to docs. by @martinfrances107 in #1396
- examples: remove random
<form>
by @gbj in #1398 - Proofreading 15_global_state.md by @aperepel in #1395
- Proofreading README.md by @aperepel in #1399
- ci: lint with clippy by @agilarity in #1379
- Proofreading 16_routes.md by @aperepel in #1405
- docs/examples: use shorthand form for
<Route/>
views when possible by @gbj in #1375 - fix:
RawText
/unquoted text nodes in SSR (closes #1384) by @gbj in #1407 - fix: closing element names wrong for
svg::
,math::
, anduse_
(closes #1403) by @gbj in #1406 - fix:
<use_/>
as typed top-level element in view by @gbj in #1410 - build(examples): make it easy to see which examples do what kind of testing by @agilarity in #1411
- docs: note about typed params on stable by @gbj in #1414
- Typo fix by @DougAnderson444 in #1412
- fix typo for WrapsChildren by @icub3d in #1402
- docs: CONTRIBUTING.md with helpful info re: CI by @gbj in #1415
- chore: resolve clippy
incorrect_clone_impl_on_copy_type
(closes #1401) by @gbj in #1418 - Fix warning message about updating a signal after it has been disposed by @jasonrhansen in #1423
- Docs proofreading and fixing the links by @aperepel in #1425
- fix: clear
<title>
correctly when navigating between pages by @gbj in #1428 - build(examples): pull up compile tasks by @agilarity in #1417
- build(examples): update Makefiles for recent examples by @gbj in #1431
- Binary search dom stuff by @g-re-g in #1430
New Contributors
- @aperepel made their first contribution in #1380
- @DougAnderson444 made their first contribution in #1412
- @icub3d made their first contribution in #1402
- @sebadob made their first contribution in #1386
- @mforsb made their first contribution in #1432
Full Changelog: v0.4.5...v0.4.6
v0.4.5
I've gotten back into a regular rhythm of patch releases pulling in some of the smaller bugfixes, but haven't had time to write release notes for each one. I should just auto-generate them, I suppose—sorry about that!
Anyway here's a quick summary of the new features included in the past few releases. The full changelog below includes various bugfixes, chores, and updates to the docs as well.
- Some useful fixes to support for
cargo leptos watch --hot-reload
leptos_axum::extract_with_state
to support extractors that use aState
, if it's been provided via context in a custom handler- The
watch
function, which functions as a more configurablecreate_effect
, including the ability to explicitly list dependencies, stop listening to them, whether to run immediately or lazily, etc. - Better 404 page support in Actix examples and templates
- Added support for adding Content-Security-Policy nonces to inline script and style tags with
use_nonce
and thenonce
feature - Rewritten
<For/>
diffing algorithm that both fixes a number of correctness issues/edge cases in<For/>
and drops ~10kb from the WASM binary
Basically, a bunch of small but really useful changes, and about a hundred bugfixes.
I also just want to give a shout-out to @agilarity, who's become one of the top contributors to the library through a very helpful focus on CI and testing. If you're ever looking for a great model of how to test a Leptos frontend app, the counters_stable
example now features two complete test suites, one in JS using Playwright and one written in Rust using wasm_bindgen_test
. This has been a huge amount of very impressive work.
Complete Changelog
v0.4.0
by @gbj in #1250- chore: remove unused variable warnings with ssr props by @tqwewe in #1244
- test(counters_stable): add missing e2e tests by @agilarity in #1251
- docs: update server fn docs by @gbj in #1252
- test(router_example): add playwright tests by @nomorechokedboy in #1247
- Add fallback support for workspace in get_config_from_str by @afiqzx in #1249
- fix: regression in ability to use signals directly in the view in stable by @gbj in #1254
- fix: hot-reloading view marker line number by @gbj in #1255
- docs: update 02_getting_started.md by @gbj in #1256
- example/readme: Link to 'VS Browser' ext; format. by @srid in #1261
- chore: new
cargo fmt
by @gbj in #1266 - feat: implement PartialEq on ServerFnError by @M1cha in #1260
- Minor: Ran cargo clippy --fix and reviewed changes. by @martinfrances107 in #1259
- fix:
HtmlElement::dyn_classes()
when adding classes by @gbj in #1265 - fix: clearing
<For/>
that has a previous sibling in release mode (fixes #1258) by @gbj in #1267 - Added watch by @maccesch in #1262
- fix: error messages in
dyn_classes
by @gbj in #1270 - docs: add docs on responses/redirects and clarification re: Axum
State(_)
extractors by @gbj in #1272 - fix: improved diagnostics about non-reactive signal access by @gbj in #1277
- fix: duplicate text nodes during
<For/>
hydration (closes #1279) by @gbj in #1281 - fix: untracked read in
<Redirect/>
by @gbj in #1280 - fix: issue with class hydration not removing classes correctly by @gbj in #1287
- fix: use
once_cell::OnceCell
rather thanstd::OnceCell
by @gbj in #1288 - leptos axum extract with state by @sjud in #1275
- examples: add 404 support in Actix examples (closes #1031) by @gbj in #1291
- fixed example for error handling by @webmstk in #1292
- Adding instructions to add a tailwind plugin to examples. by @dessalines in #1293
- chore: add
mdbook
in flake by @gbj in #1299 - test(counters_stable): add wasm testing by @agilarity in #1278
- fixed typo in parent-child doc by @webmstk in #1300
- Rework diff functionality for Each component by @g-re-g in #1296
- docs: must use
View
by @gbj in #1302 - docs: fix braces in
<Show/>
example by @gbj in #1303 - fix:
<ActionForm/>
should check origin correctly before doing a full-page refresh by @gbj in #1304 - feat: use lazy thread local for regex by @tqwewe in #1309
- test(counters_stable/wasm): enter count by @agilarity in #1307
- docs: clarify WASM target by @gbj in #1318
- update warnings to remove mention of csr as a default feature by @Heliozoa in #1313
- docs: typo by @maheshbansod in #1315
- docs: typo & punctuation by @maheshbansod in #1316
- refactor(ci): improve the organization of
cargo make
tasks by @agilarity in #1320 - feat(leptos-config): kebab-case via serde's rename_all by @filipdutescu in #1308
- fix:
<ActionForm/>
should set value even if redirected by @gbj in #1321 - feat(config): implement common traits for Env by @filipdutescu in #1324
- fix: Actix server fn
redirect()
duplicateLocation
headers by @gbj in #1326 - Bump indexmap to version 2 by @g-re-g in #1325
- fix: warning generated by new
#[must_use]
on views by @gbj in #1329 - docs: clarify
nightly
in "Getting Started" by @gbj in #1330 - fix: event delegation issue with
<input name="host">
by @gbj in #1332 - feat: allow
active_class
prop on<A/>
by @gbj in #1323 - fix: routing logic to scroll to top was broken by @gbj in #1335
- fix: check
LEPTOS_OUTPUT_NAME
correctly at compile time (closes #1337) by @gbj in #1338 - fix: un-register
<Suspense/>
from resource reads when<Suspense/>
is unmounted by @gbj in #1342 - build: run tasks from workpace or member directory by @agilarity in #1339
- docs: how not to mutate the DOM during rendering by @gbj in #1344
- fix:
server_fn
rustls
feature shouldn't pull indefault-tls
by @gbj in #1343 - Book, don't run rust code snippets and update getting started by @g-re-g in #1346
- use cfg_attr for conditional derives by @circuitsacul in #1349
- docs: improve
ServerFnError
when a server function is not found by @gbj in #1350 - docs: don't warn when a resource resolves after its scope has been disposed by @gbj in #1351
- fix: duplicated meta content during async rendering by @gbj in #1352
- ci: speed up verification by @agilarity in #1347
- fix: hydration-key conflicts between
<ErrorBoundary/>
children and fallback by @gbj in #1354 - feat: add support for adding CSP nonces by @gbj in #1348
- docs/warning: fix
<ActionForm/>
docs and add runtime warning for invalid encodings by @gbj in #1360 - ci(ci): only run on source change by @agilarity in #1357
- ci(check-examples): only run on source change by @agilarity in #1356
- fix: correctly show fallback for Transition on first load even if not hydrating by @gbj in #1362
- fix: update link to example code in book testing page by @BakerNet in #1365
- doc: previews to backup CodeSandbox by @jdevries3133 in #1169
- Hot reload bug-fix by @sebastian in #1368
- perf: exclude hydration code in CSR mode by @gbj in #1372
- fix: release lock on stored values...