Cannot read properties of null (reading 'getContext')
when i work on pattern lock on canvas getting the error.i connect the first two dots its not pblm when i connect the third dots.it get error.
Thanks in advance
Cannot read properties of null (reading 'getContext')
when i work on pattern lock on canvas getting the error.i connect the first two dots its not pblm when i connect the third dots.it get error.
Thanks in advance
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal JoshiRank #377 · 6.7K reputationPosted Feb 9, 2023, 11:55 PM EST
Hello Vinoth,
You need to check if the object is null before trying to get the value from the third dot(.).
JSON Example: ObjectA { item1:'abc', subObjA: { subItem1:'xyz', subObjAA: { item:'pqr', } } } //In the Above case we can Get a third dot (.) value like below let value = ObjectA.subObjA.subObjAA.item But if we don't have subObjAA defined then it will throw exceptions like can not read null properties. it would help if you tried the below syntax to handle null values. let value = ObjectA?.subObjA?.subObjAA.itemThanks