Crates.io | yew-consent |
lib.rs | yew-consent |
version | 0.2.0 |
source | src |
created_at | 2023-09-05 15:38:33.202242 |
updated_at | 2023-10-04 08:44:08.954537 |
description | Managing consent with Yew |
homepage | |
repository | https://github.com/ctron/yew-consent |
max_upload_size | |
id | 964450 |
size | 18,990 |
Managing user consent with Yew
Add it to your project:
cargo add yew-consent
Then, add it your application component:
#[function_component(Application)]
fn application() -> Html {
let ask = use_callback(|context, ()| html!(<AskConsent {context} />), ());
html!(
<Consent<()> {ask}>
<State/>
</Consent<()>>
)
}
And then, you can check consent later:
#[function_component(State)]
fn state() -> Html {
let consent = use_consent::<()>();
html!(
<>
<dl>
<dt>{"Consent state"}</dt>
<dd>{ format!("{consent:#?}")}</dd>
</dl>
</>
)
}
Also see the example here: example.
You can run the example using:
cd example
trunk serve