In this section, we are going to implement the type for the state object in our store, along with the initial value for the state. Follow these steps to do so:
- Create a new file called Store.ts in the src folder with the following import statement:
import { QuestionData } from './QuestionsData';
- Let's create the TypeScript types for the state of our store:
interface QuestionsState {
readonly loading: boolean;
readonly unanswered: QuestionData[] | null;
readonly postedResult?: QuestionData;
}
export interface AppState {
readonly questions: QuestionsState;
}
So, our store is going to have a questions property that, in turn, contains an array of unanswered questions or null in an unanswered property. The questions property includes whether the unanswered questions are being loaded from the server in a loading property. The questions property...