Skip to content

Commit

Permalink
Exemple should return an Fn() instead of () (#101)
Browse files Browse the repository at this point in the history
* Exemple should return an Fn() instead of ()

* restore punctuation and add missing dash

---------

Co-authored-by: Greg Johnston <[email protected]>
  • Loading branch information
heyjul and gbj authored May 19, 2024
1 parent db6f9fb commit 35c380f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server/26_extractors.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ let app = Router::new()

This context can then be accessed with a simple `use_context::<T>()` inside your server functions.

If you *need* to use `State` in a server function—for example, if you have an existing Axum extractor that requires `State`, that is also possible using Axum's [`FromRef`](https://docs.rs/axum/latest/axum/extract/derive.FromRef.html) pattern and [`extract_with_state`](https://docs.rs/leptos_axum/latest/leptos_axum/fn.extract_with_state.html). Essentially you'll need to provide the state both via context and via Axum router state:
If you *need* to use `State` in a server function—for example, if you have an existing Axum extractor that requires `State`that is also possible using Axum's [`FromRef`](https://docs.rs/axum/latest/axum/extract/derive.FromRef.html) pattern and [`extract_with_state`](https://docs.rs/leptos_axum/latest/leptos_axum/fn.extract_with_state.html). Essentially you'll need to provide the state both via context and via Axum router state:

```rust
#[derive(FromRef, Debug, Clone)]
Expand All @@ -120,7 +120,7 @@ let app = Router::new()
routes,
{
let app_state = app_state.clone();
move || provide_context(app_state.clone());
move || provide_context(app_state.clone())
},
App,
)
Expand Down

0 comments on commit 35c380f

Please sign in to comment.