Check out example codes for ".net core System.InvalidOperationException: No service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' has been registered". It will help you in understanding the concepts better.

Code Example 1

services.AddHttpContextAccessor();

Code Example 2

services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();

Learn ReactJs, React Native from akashmittal.com