Remove argument from use_hook closure (#496)
Also; update docs for said function
This commit is contained in:
1 parent
6ea076fa7f
commit
d734dc5b46
29 files changed
+53
-55
No files matched your search
@@ -77,7 +77,7 @@ pub struct LinkProps<'a> {
|
||||
/// }
|
||||
/// ```
|
||||
pub fn Link<'a>(cx: Scope<'a, LinkProps<'a>>) -> Element {
|
||||
let svc = cx.use_hook(|_| cx.consume_context::<Arc<RouterCore>>());
|
||||
let svc = cx.use_hook(|| cx.consume_context::<Arc<RouterCore>>());
|
||||
|
||||
let LinkProps {
|
||||
to,
|
||||
|
||||
@@ -34,7 +34,7 @@ pub struct RedirectProps<'a> {
|
||||
pub fn Redirect<'a>(cx: Scope<'a, RedirectProps<'a>>) -> Element {
|
||||
let router = use_router(&cx);
|
||||
|
||||
let immediate_redirect = cx.use_hook(|_| {
|
||||
let immediate_redirect = cx.use_hook(|| {
|
||||
if let Some(from) = cx.props.from {
|
||||
router.register_total_route(from.to_string(), cx.scope_id());
|
||||
false
|
||||
|
||||
@@ -28,10 +28,10 @@ pub struct RouteProps<'a> {
|
||||
/// ```
|
||||
pub fn Route<'a>(cx: Scope<'a, RouteProps<'a>>) -> Element {
|
||||
let router_root = cx
|
||||
.use_hook(|_| cx.consume_context::<Arc<RouterCore>>())
|
||||
.use_hook(|| cx.consume_context::<Arc<RouterCore>>())
|
||||
.as_ref()?;
|
||||
|
||||
cx.use_hook(|_| {
|
||||
cx.use_hook(|| {
|
||||
// create a bigger, better, longer route if one above us exists
|
||||
let total_route = match cx.consume_context::<RouteContext>() {
|
||||
Some(ctx) => ctx.total_route,
|
||||
|
||||
@@ -37,7 +37,7 @@ pub struct RouterProps<'a> {
|
||||
/// Will fallback to HashRouter is BrowserRouter is not available, or through configuration.
|
||||
#[allow(non_snake_case)]
|
||||
pub fn Router<'a>(cx: Scope<'a, RouterProps<'a>>) -> Element {
|
||||
let svc = cx.use_hook(|_| {
|
||||
let svc = cx.use_hook(|| {
|
||||
cx.provide_context(RouterCore::new(
|
||||
&cx,
|
||||
RouterCfg {
|
||||
|
||||
Reference in new issue
Block a user