Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
beyaz committed Feb 7, 2024
1 parent c2ce566 commit ec5091b
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion ReactWithDotNet/FC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ protected override Task constructor()

return Task.CompletedTask;
}

static void TryUpdateProps(object targetInMethod, object target)
{
if (targetInMethod is not null)
{
foreach (var fieldInfo in targetInMethod.GetType().GetFields())
{
if (char.IsUpper(fieldInfo.Name[0]))
{
var propValue = fieldInfo.GetValue(targetInMethod);

fieldInfo.SetValue(target, propValue);
}
}
}
}

protected override Element render()
{
Expand All @@ -91,6 +107,8 @@ protected override Element render()
if (_target is null && state.Scope is not null)
{
InitializeTarget();

TryUpdateProps(renderFuncWithScope?.Target,_target);
}

MethodInfo methodInfo = null;
Expand All @@ -115,13 +133,20 @@ protected override Element render()

protected override async Task<Element> renderAsync()
{
if (renderFuncAsyncWithScope is not null)
if (renderFuncAsyncWithScope is not null && state.Scope is null)
{
var fc = await renderFuncAsyncWithScope();

return fc?.Invoke(this);
}

if (_target is null && state.Scope is not null)
{
InitializeTarget();

TryUpdateProps(renderFuncAsyncWithScope?.Target,_target);
}

MethodInfo methodInfo = null;
if (TryResolveMethodInfo(state.RenderMethodNameWithToken, ref methodInfo))
{
Expand Down

0 comments on commit ec5091b

Please sign in to comment.