I have this javascript file which is containing styles in an object for a React app:
const styles = { fonts: { Georgia: 'Georgia, \'Times New Roman\', Times, serif', }, App: { textAlign: 'center', fontFamily: this.fonts.Georgia, }, }; module.exports = styles; fontFamily: this.fonts.Georgia would reference App: { fonts: '' } object, but what I want to do is to access the already defined fonts object inside styles. How can I do that?
What works is:
const fonts = { Georgia: 'Georgia, \'Times New Roman\', Times, serif', }; const styles = { App: { textAlign: 'center', fontFamily: fonts.Georgia, }, }; module.exports = styles; This is works in this case, but the upper solution would be much nicer.
this.styles.fonts.Georgianot worked.thisnot being available on a variable (and only inside a function), this is aboutthisbeing too deep in the tree, and thus not being able to access properties higher up the tree with it.