Answer the question
In order to leave comments, you need to log in
Is it possible to apply an array key in a class method?
Good morning!
Today I encountered a small bug, which I brought to the end of the implementation of an OOP solution in TypeScript for a mobile application with the Expo SDK, and the compiler brought bad news:
TypeError: Cannot read property 'feedTitle' of undefined
And the error itself referred to an excerpt from a whole example code:
import * as React from 'react';
import { Text, View } from 'react-native';
import { StoresFeed } from '../handlers/stores/homepage/Feed';
export function Stores(){
return (
<React.Fragment>
<Text style={pageStyle.feedTitle}>Ближайшие магазины</Text>
<Text style={pageStyle.feedTitle}>Лучшие товары</Text>
<Text style={pageStyle.listTitle}>Лучшие категории</Text>
<Text style={pageStyle.feedTitle}>Выгодные цены</Text>
<Text style={pageStyle.listTitle}>Категории</Text>
</React.Fragment>
);
}
const pageStyle = new StoresFeed('ui-change',0).eventStart();
Answer the question
In order to leave comments, you need to log in
Enable strictNullChecks to catch such errors at compile time
PS
storesFeed: any;
constructor(event: any,type: any){
what is the point in TypeScript if you write any everywhere?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question