mirror of
https://github.com/adoyle0/thaw.git
synced 2025-02-02 08:34:15 -05:00
fix: ssr mode input default value (#163)
This commit is contained in:
parent
4fe3dfd23f
commit
aa793e16e1
2 changed files with 12 additions and 1 deletions
|
@ -140,6 +140,16 @@ pub fn Input(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let input_value: Option<String>;
|
||||||
|
#[cfg(feature = "ssr")]
|
||||||
|
{
|
||||||
|
input_value = Some(value.get_untracked());
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "ssr"))]
|
||||||
|
{
|
||||||
|
input_value = None;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
const INNER_ATTRS: [&str; 4] = ["type", "class", "disabled", "placeholder"];
|
const INNER_ATTRS: [&str; 4] = ["type", "class", "disabled", "placeholder"];
|
||||||
|
@ -173,6 +183,7 @@ pub fn Input(
|
||||||
<input
|
<input
|
||||||
{..attrs}
|
{..attrs}
|
||||||
type=move || variant.get().as_str()
|
type=move || variant.get().as_str()
|
||||||
|
value=input_value
|
||||||
prop:value=move || {
|
prop:value=move || {
|
||||||
value_trigger.track();
|
value_trigger.track();
|
||||||
value.get()
|
value.get()
|
||||||
|
|
|
@ -23,7 +23,7 @@ where
|
||||||
T: Default + Clone + FromStr + ToString + 'static,
|
T: Default + Clone + FromStr + ToString + 'static,
|
||||||
{
|
{
|
||||||
let input_value = create_rw_signal(String::default());
|
let input_value = create_rw_signal(String::default());
|
||||||
create_effect(move |prev| {
|
Effect::new_isomorphic(move |prev| {
|
||||||
value.with(|value| {
|
value.with(|value| {
|
||||||
let value = value.to_string();
|
let value = value.to_string();
|
||||||
if let Some(prev) = prev {
|
if let Some(prev) = prev {
|
||||||
|
|
Loading…
Add table
Reference in a new issue