Rajesh
Rajesh sr solutions architect @corebts | former #mvp | #ai #bots #ml #office365. Currently I'm helping my customers on modernization and successful adoption of cloud solutions.

SharePoint Framework: error TS2339: Property items does not exist on type Readonly

SharePoint Framework: error TS2339: Property items does not exist on type Readonly

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

  1. Create an interface with the state objects as properties, as below
    1
    2
    3
    4
    
    export interface IQuoteState {
      error?: string;
      quoteItems?: IQuoteItem[];
    }
    
  2. 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: []
     };
      }
    }
    

comments powered by Disqus