Answer the question
In order to leave comments, you need to log in
Strange behavior when inheriting a primitive in React Native?
Why does this construction work fine in browser but not in React Native?
class Alias extends String {
toJson() {
try {
let value = this.concat()
if (value) {
value = JSON.parse(value);
}
return value;
} catch (error) {
throw new Error(`It isn't JSON string.`)
};
}
}
export class Aliases {
constructor(aliases) {
if (!aliases) throw new Error('Array of aliases are required in params.')
aliases.forEach(alias => {
this[alias.code] = new Alias(alias.value);
})
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question