v0.1.0 #306
gbj
announced in
Announcements
v0.1.0
#306
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Finally, here's the release for version
0.1.0
. Thanks to everyone who's been working with the alpha, beta, and bleeding-edge versions over the last few weeks to help get everything ready.Most of the release notes below are copied from the
0.1.0-alpha
release, but include a few updates. All these changes are relative to0.0.22
.Features
More flexible rendering
You can now easily mix and match different types of node in a
Fragment
, which previously needed to be aVec
of all the same types (like aVec<Fragment>
).In fact, the
<>
fragment itself is optional.Typed HTML elements
HTML elements generated by the
view!
macro are now typed, and implementDeref
to give a correctly-typedweb_sys
element.store_value
You can now store non-reactive values in the reactive system to take advantage of the same
Copy + 'static
reference system without the overhead or abstraction leak of storing something in a signal. This is useful for objects you need to reference in multiple places throughout your application without cloning.Signal<T>
andSignalSetter<T>
abstractionsThese wrappers allow you to define APIs that can take any kind of signal. For example,
Signal<T>
can be aReadSignal
,RwSignal
,Memo
, or derived signal. This is especially useful when defining components interfaces. (There's even aMaybeSignal
for types that may just beT
or may be aSignal<T>
.)Massively improved Rust Analyzer support
DX with this new system is much better. You'll see hugely improved language-server integration for the
view!
macro, including features like doc comments for HTML elements, autocompletion for component properties, clicking to go to the definition of a component, type hints for component arguments, etc.Inline documentation in the
#[component]
macroYou can now document components and their properties directly in the
#[component]
macro like this:The macro will automatically generate docs for the components and for each of its props.
#[prop]
attributes for component propsYou can use the
#[prop]
attribute macro to mark component props in several ways:#[prop(into)]
: This will call.into()
on any value passed into the component prop. (For example,you could apply
#[prop(into)]
to a prop that takes Signal, which wouldallow users to pass a ReadSignal or RwSignal
and automatically convert it.)
#[prop(optional)]
: If the user does not specify this property when they use the component,it will be set to its default value. If the property type is
Option<T>
, values should be passedas
name=T
and will be received asSome(T)
.#[prop(optional_no_strip)]
: The same asoptional
, but requires values to be passed asNone
orSome(T)
explicitly. This means that the optional property can be omitted (and beNone
), or explicitlyspecified as either
None
orSome(T)
.#[prop(default = X)]
: The property is optional, and will be set to the default value provided if it is not passed.tracing
supportWe've added support for debugging using the
tracing
crate, integrated into both the renderer and the reactive system. This means that when an effect or an event listener fires, you can usetrace!(...)
to get an insight into the flow of your program. Seeleptos_dom/examples/test-bench
for an example setup; a separate crate to make this tracing setup easier will be forthcoming.cargo-leptos
integration improvementscargo-leptos 0.1.2
and the Actix/Axum integrations in0.1.0
now work together seamlessly, allowing you to create full-stack applications with as little boilerplate as possible.And much more!
<Router/>
in a<div>
for no obvious reasonview
macroBreaking Changes
Here are a few things to watch out for as you migrate:
cargo-leptos
already and run into any issues (for example, with the path of a JS or Wasm file), be sure to check out the latest examples and the starter. The extra structures here have changed a bit over time as we've tried to figure out the best patterns. Cloning the starter and adding your existing application code should work fine.-> impl IntoView
<For/>
component now takes aview
property, instead of you passing the view function as the child of the component<Route/>
component takes aview
property instead ofelement
for consistencychildren
properties are now typedBox<dyn Fn(Scope) -> Fragment>
view!
macro returns distinct structures, which are all different types. In other words, this code no longer compilesbecause the first branch now returns
HtmlElement<P>
while the second returnsHtmlElement<Span>
.In this case, simply add
.into_any()
to each to returnHtmlElement<AnyElement>
from both. In general, you can always call.into_view(cx)
to return a wrappingView
type instead.This discussion was created from the release v0.1.0.
Beta Was this translation helpful? Give feedback.
All reactions