I Just created a basic spfx webpart with react but getting bellow error:
{ "resource": "/c:/Node_Dev/CRUD_React/src/webparts/crudReact001/CrudReact001WebPart.ts", "owner": "typescript", "code": "2611", "severity": 8, "message": "'dataVersion' is defined as a property in class 'BaseClientSideWebPart', but is overridden here in 'CrudReact001WebPart' as an accessor.", "source": "ts", "startLineNumber": 35, "startColumn": 17, "endLineNumber": 35, "endColumn": 28 }
My Code:
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Version } from '@microsoft/sp-core-library';
import {
IPropertyPaneConfiguration,
PropertyPaneTextField
} from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import * as strings from 'CrudReact001WebPartStrings';
import CrudReact001 from './components/CrudReact001';
import { ICrudReact001Props } from './components/ICrudReact001Props';
export interface ICrudReact001WebPartProps {
description: string;
}
export default class CrudReact001WebPart extends BaseClientSideWebPart<ICrudReact001WebPartProps> {
public render(): void {
const element: React.ReactElement<ICrudReact001Props> = React.createElement(
CrudReact001,
{
description: this.properties.description
}
);
ReactDom.render(element, this.domElement);
}
protected onDispose(): void {
ReactDom.unmountComponentAtNode(this.domElement);
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('description', {
label: strings.DescriptionFieldLabel
})
]
}
]
}
]
};
}
}
You can just delete 'datavaersion' method, it's compatible with SPFx v1.10 but will get an error when you install V1.11.