Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventCallback for second binding value not work #16937

Open
nguyenvanbien95 opened this issue Nov 9, 2019 · 1 comment
Assignees

Comments

@nguyenvanbien95
Copy link

@nguyenvanbien95 nguyenvanbien95 commented Nov 9, 2019

I have two values for binding form parent component to child component.

First value is binded success but second value is not work.

To Reproduce

Child.cs

    // display Value1, Value2

    @code {

    [Parameter] Type1 Value1{ get; set; }
    [Parameter] EventCallback<Type1 > Value1Changed { get; set; }
    [Parameter] Type2 Value2{ get; set; }
    [Parameter] EventCallback<Type2 > Value2Changed { get; set; }

    override async Task OnInitializedAsync() 
    {
            var dbData = await Service.GetAsync();
            Value1 = dbData.Item1;
            Value2 = dbData.Item2;
            await Value1Changed.InvokeAsync(Value1);
            await Value2Changed.InvokeAsync(Value2);
    }
    }

Parent.cs

    <Child @bind-Value1="Value1" @bind-Value2="Value2"></Child>

    @code {
    Type1 Value1{ get; set; }
    Type2 Value2{ get; set; }
    }

When child Initialized, Value1 is send back to parent, Value2 is changed to value of Value2 of parent(not change value in parent).
Parent load: Value1 = 0, Value2 = 0
Child load: Value1 = 1, Value2 = 2
=> after send to Parent:
Parent: Value1 = 1, Value2 = 0
Child : Value1 = 1, Value2 = 0

It seem not good practice. I can change code for a object contain both. But I want to sure this is not a bug?

Further technical details

  • ASP.NET Core version 3.0
  • Include the output of dotnet --info
    .NET Core SDK (reflecting any global.json):
    Version: 3.0.100
    Commit: 04339c3a26

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33

  • The IDE is visual studio 2019 v16.3.7
@javiercn

This comment has been minimized.

Copy link
Member

@javiercn javiercn commented Nov 11, 2019

@nguyenvanbien95 thanks for contacting us.

@SteveSandersonMS thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.