function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brendan O'Grady 3Brendan O'Grady 3 

Getting an error of: "Cannot read property 'record' of undefined Type Error [1,1]

I'm trying to create my first custom LWC for my own org. I want to just put a smiley face image in the middle of the component with some text at the top. Here is the code below:

js:
import { LightningElement } from 'lwc';
export default class SmileyFinal extends LightningElement 
{
    pictureUrl = 'https://en.wikipedia.org/wiki/Smiley#/media/File:SNice.svg'; 
}

html:
<template>
    <body> 
        <div class="slds-m-around_medium">
            <h1 class="slds-text-heading_small">Welcome to Brendan's Smiley Class</h1>
            <p>The first of many projects.</p>
        </div>
        <div class="slds-container_center">
                <img src={pictureUrl}>
        </div>
    </body>
</template>

css:
body{    
    font-family: Helvetica; 
    color: black; 
    text-align: center;
    justify-content: center;
    margin: 0; 
}
Abhishek BansalAbhishek Bansal
Hi Brendan,

Can you modify your js code as below:
import { LightningElement , track} from 'lwc';
export default class SmileyFinal extends LightningElement 
{
    @track pictureUrl = 'https://en.wikipedia.org/wiki/Smiley#/media/File:SNice.svg'; 
}

Let me know if this solves your problem.

Thanks,
Abhishek Bansal.
NK@BITNK@BIT
LWC Wire Function “Cannot read property ‘fields’ of undefined”. Try to check for null. (https://nitinkhunalsalesforce.wordpress.com/2021/04/13/lwc-wire-function-cannot-read-property-fields-of-undefined/)