mrpmorris / Fluxor

Fluxor is a zero boilerplate Flux/Redux library for Microsoft .NET and Blazor.
MIT License
1.27k stars 146 forks source link

Blazor server app in used Redux(Fluxor) in asp .net core error Unable to resolve service for type 'Fluxor.IFeature` while attempting to activate 'Fluxor.State` #468

Closed NamanGajjar26 closed 1 month ago

NamanGajjar26 commented 8 months ago

I am using blazor server application in asp .net core
there are Getcustomer razor page

`

Getcustomer

 <button class="btn btn-primary" @onclick="GetAllCustomers">Get All Customer</button>

@code {

    [Inject]
    private IState<CustomerState> CustomerState { get; set; }

    private async Task GetAllCustomers()
    {
         Dispatcher.Dispatch(new GetAllCustomersAction());
    }
   }    `

this call form console application in services make the three cs file CustomerState

` [FeatureState] public class CustomerState { public List Customers { get; private set; }

  public CustomerState(List<Customers> customers)
  {
      Customers = customers;
  }

}` than make GetAllCustomersAction cs

public class GetAllCustomersAction { }

than make CustomerReducer cs

[ReducerMethod] public static CustomerState OnGetAllCustomers(CustomerState state, GetAllCustomersAction action) { using (var dbContext = new OnionArchitecturePro1Context()) // Replace YourDbContext with your actual DbContext class { var customers = dbContext.Customers.ToList(); return new CustomerState(customers); } }

and add startup cs in this service add

services.AddFluxor(options => { options.ScanAssemblies(typeof(Program).Assembly); options.UseReduxDevTools(); });

stagep commented 8 months ago

You need to initialize the store. Add the following to the GetCustomer.razor page.

<Fluxor.Blazor.Web.StoreInitializer />
veekayit commented 6 months ago

Hi, Am using Blazor 8, and getting this error when I try to reload the page.. Please let me know how to resolve.

mrpmorris commented 1 month ago

Can you send me a repro?