Skip to content

Commit

Permalink
🐛 fix(Datatable): not render in SSR server (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem authored Jan 26, 2024
1 parent 0ee4c9a commit 4a64473
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public void SetValueWithNoEffect(TValue? value)
/// </summary>
public bool HasValue => _hasValue;

/// <summary>
/// Indicate whether this property is computed, only used for computed property
/// TODO: maybe add a new class for computed property in the future
/// </summary>
public bool Computed { get; set; }

public event Action<TValue?, TValue?>? OnValueChange;

public void NotifyChange(TValue? newValue, TValue? oldValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private ObservableProperty<TValue> GetProperty<TValue>(TValue? @default, string
public TValue? GetComputedValue<TValue>(Expression<Func<TValue>> valueExpression, string name)
{
var property = GetProperty<TValue>(default, name);
if (!property.HasValue)
if (!property.Computed)
{
var valueFactory = valueExpression.Compile();
property.ValueFactory = valueFactory;
Expand All @@ -73,6 +73,7 @@ private ObservableProperty<TValue> GetProperty<TValue>(TValue? @default, string
SetValue(value, name);
});
}
property.Computed = true;
}

return property.Value;
Expand All @@ -81,7 +82,7 @@ private ObservableProperty<TValue> GetProperty<TValue>(TValue? @default, string
public TValue? GetComputedValue<TValue>(Func<TValue> valueFactory, string[] dependencyProperties, string name)
{
var property = GetProperty<TValue>(default, name);
if (!property.HasValue)
if (!property.Computed)
{
property.ValueFactory = valueFactory;
property.Value = valueFactory();
Expand All @@ -94,6 +95,8 @@ private ObservableProperty<TValue> GetProperty<TValue>(TValue? @default, string
SetValue(value, name);
});
}

property.Computed = true;
}

return property.Value;
Expand Down

0 comments on commit 4a64473

Please sign in to comment.