Supplying state to bind against

The idea behind binding with React is that we have a state that we need to bind to. In the case of creating data that we want to display on the screen, our state can be as simple as an interface describing the properties that we want to use. For a single contact, this translates to our state looking like this:

export interface IPersonState {  FirstName: string,  LastName: string,  Address1: string,  Address2: StringOrNull,  Town: string,  County: string,  PhoneNumber: string;  Postcode: string,  DateOfBirth: StringOrNull,  PersonId : string}

Note that we have created a union type called StringOrNull as a convenience. We will place this in a file called Types.tsx so that it looks like this:

export type StringOrNull ...

Get Advanced TypeScript Programming Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.