I have declared a object in my state, se code:
this.state = {
  attendtext: "Attend",
  showPanel: false,
  attendespanel: null,
  user: this.user
};
I update it with the usual setState:
if (attenduser.isSiteAdmin) {
  this.setState(prevState => ({
    user: {
      ...prevState.user,
      isSiteAdmin: true
    }
  }));
}
But I cant access this objects properties. For example:
this.state.user.isSiteAdmin 
Above is not valid. How come?
My interface:
export interface UserItem {
  Key?: string;
  Username?: string;
  user?: {
    title: string,
    emailaddress: string,
    isSiteAdmin: boolean
  };
}
I also tried to set the state with:
this.state = {
  attendtext: "Attend",
  showPanel: false,
  attendespanel: null,
  user: { title: "", emailaddress: "", isSiteAdmin: false }
};
However, it gets red "Object literal may only specify known properties, and 'title' does not exist in type 'UserItem[]'" which happens for all the properties in the user object, even if they are declared in the interface.
 
    