use wasm_bindgen::prelude::*; use web_sys::HtmlInputElement; use yew::prelude::*; fn main() { yew::Renderer::::new().render(); } #[function_component(App)] pub fn app() -> Html { // TODO: use_state_eq? let query_results_handle = use_state(QueryResultListProps::default); // Callback that executes query on every change to input // TODO: make async? let on_change_cb = { Callback::from(move |e: InputEvent| { let target = e.target(); let input = target.and_then(|t| t.dyn_into::().ok()); if let Some(input) = input { // TODO: try not to copy here let input = input.value(); query_results_handle.set(QueryResultListProps { results: vec![QueryResult { res: input }] }); } }) }; html! {
} } #[function_component(QueryResultList)] fn query_result(QueryResultListProps { results }: &QueryResultListProps) -> Html { html! { } } #[derive(Default, Properties, PartialEq)] struct QueryResultListProps { results: Vec, } #[derive(PartialEq)] struct QueryResult { res: String, } impl ToHtml for QueryResult { fn to_html(&self) -> Html { html! {
  • { self.res }
  • } } }