Skip to content

Commit

Permalink
Merge pull request #82 from StarArawn/forward-attrs
Browse files Browse the repository at this point in the history
Forwarded attributes on functional widgets
  • Loading branch information
StarArawn committed Feb 18, 2022
2 parents c249488 + 1b36520 commit 137c421
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kayak_render_macros/examples/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use kayak_render_macros::{rsx, use_state, widget, WidgetProps};
#[derive(WidgetProps, Clone, Default, Debug, PartialEq)]
#[allow(dead_code)]
struct TestProps {
/// A test prop
foo: u32,
#[prop_field(Styles)]
styles: Option<Style>,
Expand All @@ -15,6 +16,7 @@ struct TestProps {
}

#[widget]
/// A test widget
fn Test(props: TestProps) {
let _ = use_state!(props.foo);
let children = props.get_children();
Expand Down
2 changes: 2 additions & 0 deletions kayak_render_macros/src/function_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ pub fn create_function_widget(f: syn::ItemFn, _widget_arguments: WidgetArguments
return TokenStream::new();
};

let attrs = f.attrs;
let block = f.block;
let vis = f.vis;

let kayak_core = get_core_crate();

TokenStream::from(quote! {
#(#attrs)*
#[derive(Default, Debug, PartialEq, Clone)]
#vis struct #struct_name #impl_generics {
pub id: #kayak_core::Index,
Expand Down

0 comments on commit 137c421

Please sign in to comment.