12 } 13 14 impl Component for Main { 15 fn render(&self) -> Node { 16 let key = String::from_str("message"); 17 let message = self.state.borrow().get(&key).unwrap().clone(); 18 v("div", 19 vec![attribute("class", text_value("hoge"))], 20 vec![ 21 v("p", vec![], vec![ 22 Node::Text(message.clone()), 23 ]), 24 v("input", vec![ 25 attribute("value", AttributeValue::Text(message.clone())), 26 attribute("change", AttributeValue::EventHandler(Box::new({ 27 let state = self.state.clone(); 28 move |e: &mut Event| { 29 let key = String::from_str("message"); 30 let mut st = state.borrow_mut(); 31 let node = e.target.as_mut().unwrap(); 32 st.insert(key, node.prop_get_str("value")); 33 } 34 }))), 35 ], vec![]) 36 ] 37 ) 38 } 39 } onchangeͷΠϕϯτϋϯυϥͰstateΛߋ৽ stateͷ༰Λදࣔ