cargo leptos 0.5.3
v0.5.3

latest releases: 0.7.0-rc1, 0.7.0-rc0, 0.7.0-preview2...
11 months ago

v0.5.3

Along with the usual set of bugfixes and small improvements, there are two noteworthy additions in this release.

Improved rust-analyzer support in #[component] macro body

Good LSP support for proc macros is hard, because proc macros depend on parsing a stream of input into a valid Rust syntax tree, but while typing you are constantly creating a stream of new, invalid trees. This release tweaks how the #[component] macro emits code in order to enable better rust-analyzer support within the body of components.

If you've disabled rust-analyzer inside #[component] for better DX, try toggling that off and see if this is a better experience than it was before!

Apologies for any regressions this causes. Please report any issues that arise.

There is still additional work to be done to support rust-analyzer in the view! macro. The hoped-for improvements here are solely inside the #[component] body.

Optional Context <Provider/> Component

Since 0.5.0, there've been a couple instances of bugs or confusing behavior related to the fact that context now follows the reactive graph, not the component tree (see #1986, #2038).

This release includes a <Provider/> component that provides a certain value via context only to its children:

#[component]
pub fn App() -> impl IntoView {
    // each Provider will only provide the value to its children
    view! {
        <Provider value=1u8>
            // correctly gets 1 from context
            {use_context::<u8>().unwrap_or(0)}
        </Provider>
        <Provider value=2u8>
            // correctly gets 2 from context
            {use_context::<u8>().unwrap_or(0)}
        </Provider>
        // does not find any u8 in context
        {use_context::<u8>().unwrap_or(0)}
    }
}

provide_context continues working as it has since 0.5.0, and if you're using it without problems you can ignore this, or use it if you prefer to aesthetics. If you're in a situation where you need to provide multiple context values of the same type and ensure that they are scoped correctly and that siblings do not overwrite one another, use <Provider/>. If you have no idea what I mean, check the issues above for examples of the bugs this fixes.

Complete Changelog

  • fix: relax 'static bound on as_child_of_current_owner by @gbj in #1955
  • IntoView and IntoAttribute for std::fmt::Arguments improvements by @tqwewe in #1947
  • workflows: bump setup-node to version 4. by @martinfrances107 in #1944
  • Minor: bumped tj-actions/changed-files to @39. by @martinfrances107 in #1942
  • feat: add new method to Trigger by @tqwewe in #1935
  • feat: impl IntoAttribute for Cow<'static, str> by @tqwewe in #1945
  • chore: Add server to procMacro for helix as well by @kerkmann in #1951
  • Allow arbitrary attributes for anchor component by @koopa1338 in #1953
  • fix: add leptos_axum::build_static_routes (closes #1843) by @gbj in #1855
  • Implement IntoAttribute for TextProp by @SleeplessOne1917 in #1925
  • chore: fix clippy on login_with_token_csr_only by @gbj in #1965
  • fix: router docs feature stable to nightly by @chrisp60 in #1959
  • chore: typed-builder and typed-builder-macro - bumped version numbers. by @martinfrances107 in #1958
  • fix: leptos_router::params_map! by @chrisp60 in #1973
  • docs: Fix 08_parent_child.md callback example code. by @gibbz00 in #1976
  • Fix [] url in 12_transition.md by @gibbz00 in #1980
  • book: point leptos_server docs.rs url to latest version. by @gibbz00 in #1982
  • docs: clarify need to provide context in two places for server functions by @gbj in #1983
  • fix: treat Suspense as containing a Set of resources, not a counter by @gbj in #1985
  • examples: fix hackernews_js_fetch style.css path (closes #1992) by @gbj in #1994
  • fix: run <ErrorBoundary/> in a child so siblings don't collide (closes #1987) by @gbj in #1991
  • examples: remove incorrect CSR information for hackernews_js_fetch example by @gbj in #1997
  • fix: correctly reset island/not-island state of SSRed Suspense streaming into island (closes #1996) by @gbj in #2000
  • book: Fix link in metadata.md by @gibbz00 in #1999
  • docs: fix CodeSandbox for resources by @gbj in #2002
  • docs: remove outdated APP_ENVIRONMENT variable by @gbj in #2013
  • feat: Action::new and Action::server by @chrisp60 in #1998
  • chore: remove duplicate benchmarks in leptos_reactive by @gbj in #2014
  • docs: add note about context shadowing (closes #1986) by @gbj in #2015
  • re-export slice! by @blorbb in #2008
  • fix: allow nested functions in Attribute (closes #2023) by @gbj in #2027
  • fix: use create_effect for <Portal/> to avoid hydration issues (closes #2010) by @gbj in #2029
  • impl Default for TextProp by @blorbb in #2016
  • Docs: ActionForm examples for complex arguments by @chrisp60 in #2017
  • fix document book input name query by @datewu in #2024
  • Minor: stop using std::fmt, instead used core::fmt. by @martinfrances107 in #2033
  • Updates to Leptos Book by @diversable in #2036
  • examples: add CSR with server functions example (closes #1975) by @gbj in #2031
  • Have fetch example conform to docs guidance around using and in conjunction by @MoonKraken in #2035
  • feat: <Provider/> component to fix context shadowing (closes #2038) by @gbj in #2040
  • updated axum session to latest 0.9 in examples by @genusistimelord in #2049
  • ci(examples): fix portal test by @gbj in #2051
  • docs: add warning for nested Fn in attribute (see #2023) by @gbj in #2045
  • fix: correctly mark Trigger as clean when it is re-tracked (closes #1948, #2048) by @gbj in #2059
  • Add instruction to install trunk to examples/README.md by @hpepper in #2064
  • fix: dispose previous route or outlet before rendering new one (closes #2070) by @gbj in #2071
  • ci(leptos): run ci on change instead of check by @agilarity in #2061
  • fix: make prop serialization opt-in for devtools (closes #1952) by @gbj in #2081
  • fix: improved rust-analyzer support in #[component] macro? by @gbj in #2075

New Contributors

Full Changelog: v0.5.2...v0.5.3

Don't miss a new leptos release

NewReleases is sending notifications on new releases.