SharePoint Framework: error TS2339: Property items does not exist on type Readonly
![SharePoint Framework: error TS2339: Property items does not exist on type Readonly](https://3.bp.blogspot.com/-VzKfgnBjEIk/WfXTMe-j7JI/AAAAAAAAe_Y/vpTQDjpNkgETm9wM4uE04LXI2-ixLVchQCLcBGAs/s640/Screen%2BShot%2B2017-10-29%2Bat%2B6.09.12%2BAM.png)
When you encounter the below error, while using state object in react based webpart created by yeoman generator.
error TS2339: Property ‘items’ does not exist on type ‘Readonly<{}>’
Follow these steps
- Create an interface with the state objects as properties, as below
1 2 3 4
export interface IQuoteState { error?: string; quoteItems?: IQuoteItem[]; }
- 2.Use the interface in your component class as below
1 2 3 4 5 6 7 8 9
export default class Quotes extends React.Component<IQuoteProps, IQuoteState> { constructor(props) { super(props); this.state = { error: null, censusItems: [] }; } }