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

Implementing more of the question page

Let's carry out some more steps to implement the question page a little more:

  1. In QuestionsData.ts, add a function that will simulate a web request to get a question:
export const getQuestion = async (  questionId: number): Promise<QuestionData | null> => {  await wait(500);  const results     = questions.filter(q => q.questionId === questionId);  return results.length === 0 ? null : results[0];};

We have used the array filter method to get the question for the passed-in questionId.

  1. Moving on to QuestionPage.tsx, let's import the function we just created, along with the question interface:
import { QuestionData, getQuestion } from './QuestionsData';
  1. We are going to store the question in the state when the ...
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