[SalesForce] Invalid decorator usage. Supported decorators (api, wire, track) should be imported from “lwc”

I started working with Lightning Web Components and was doing the Quick Start: Lightning Web Components project, on deploying source to org, I am getting the following error in VS Code output Panel

SyntaxError: /home/sfdc/tools/lwc/0.34.7/helloWorld.js: LWC1100: Invalid decorator usage. Supported decorators (api, wire, track) should be imported from "lwc"

Below is code in helloWorld.js as mentioned in trailhead

import { LightningElement } from 'lwc';
export default class HelloWorld extends LightningElement {
    @track greeting = 'World';
    changeHandler(event) {
        this.greeting = event.target.value;
    }
}

How do I import these decorators from 'lwc'?

Best Answer

You must add them to your import statement. You’re using @track, so you should have the following:

import { LightningElement, track } from 'lwc';

You can read more about reactive properties, how to import them and use them here.

You should have a look to the whole Dev Guide to learn more about LWC.

Related Topic