Skip to Main Content
ASP.NET Core 3 and React
book

ASP.NET Core 3 and React

by Carl Rippon
December 2019
Intermediate to advanced content levelIntermediate to advanced
598 pages
12h 21m
English
Packt Publishing
Content preview from ASP.NET Core 3 and React

Setting up the client connection

Let's carry out the following steps to create a function that sets up the SignalR client connection object:

  1. Open QuestionPage.tsx and import the following from the SignalR client:
import {  HubConnectionBuilder,  HubConnectionState,  HubConnection,} from '@aspnet/signalr';
  1. We're going to create a function to set up the SignalR connection in the QuestionPage component, just below where the question state is declared:
const [question, setQuestion] = useState<QuestionData | null>(null);const setUpSignalRConnection = async (questionId: number) => {  // TODO - setup connection to real-time SignalR API  // TODO - handle Message function being called   // TODO - handle ReceiveQuestion function being called  // TODO ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET Core 5 and React - Second Edition

ASP.NET Core 5 and React - Second Edition

Carl Rippon
ASP.NET Core 5 for Beginners

ASP.NET Core 5 for Beginners

Andreas Helland, Vincent Maverick Durano, Jeffrey Chilberto, Ed Price

Publisher Resources

ISBN: 9781789950229Supplemental Content