Skip to content

Commit c80e647

Browse files
committed
fix: allowed statenames other than state
This was a flabbergasting case of 'oh, I'll fix this later'.
1 parent 659b911 commit c80e647

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/perseus-macro/src/auto_scope.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ pub fn template_impl(input: TemplateFn) -> TokenStream {
111111
} = input;
112112

113113
let arg = &fn_args[1];
114-
let state_arg = match arg {
115-
FnArg::Typed(PatType { ty, .. }) => match &**ty {
116-
Type::Reference(TypeReference { elem, .. }) => elem,
114+
let (state_pat, state_arg) = match arg {
115+
FnArg::Typed(PatType { ty, pat, .. }) => match &**ty {
116+
Type::Reference(TypeReference { elem, .. }) => (pat, elem),
117117
_ => return syn::Error::new_spanned(arg, "the state argument must be a reference (e.g. `&MyStateTypeRx`); if you're using unreactive state (i.e. you're deriving `UnreactiveState` instead of `ReactiveState`), you don't need this macro!").to_compile_error()
118118
},
119119
FnArg::Receiver(_) => unreachable!(),
@@ -127,7 +127,7 @@ pub fn template_impl(input: TemplateFn) -> TokenStream {
127127
#(#attrs)*
128128
#vis fn #name<'__page, G: ::sycamore::prelude::Html>(
129129
cx: ::sycamore::prelude::BoundedScope<'_, '__page>,
130-
state: &'__page #state_arg,
130+
#state_pat: &'__page #state_arg,
131131
// Capsules have another argument for properties
132132
#props_arg
133133
) -> #return_type {

0 commit comments

Comments
 (0)