Improve text area value setting.
This commit is contained in:
parent
71871f7189
commit
0645abe895
2 changed files with 9 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "bootstrap-rs"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
authors = ["Thomas Gideon <cmdln@thecommandline.net>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ pub struct Props {
|
|||
pub class: String,
|
||||
#[prop_or_default]
|
||||
pub style: String,
|
||||
#[prop_or_default]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl Component for TextArea {
|
||||
|
@ -40,7 +42,7 @@ impl Component for TextArea {
|
|||
type Properties = Props;
|
||||
|
||||
fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
|
||||
let state = String::default();
|
||||
let state = props.value.clone();
|
||||
Self { props, state, link }
|
||||
}
|
||||
|
||||
|
@ -55,7 +57,11 @@ impl Component for TextArea {
|
|||
}
|
||||
|
||||
fn change(&mut self, props: Self::Properties) -> ShouldRender {
|
||||
render_on_change(&mut self.props, props)
|
||||
let should_render = render_on_change(&mut self.props, props);
|
||||
if should_render {
|
||||
self.state = self.props.value.clone();
|
||||
}
|
||||
should_render
|
||||
}
|
||||
|
||||
fn view(&self) -> Html {
|
||||
|
|
Loading…
Reference in a new issue