-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global styles 'Unresolved variable' error #50
Comments
Hi @Christopher2K, sorry for delay. |
Hello, I am experiencing a similar problem. I am using Expo. EStyleSheet.build({
'$blue': '#0275d8',
'$orange': '#FB7723',
}); Then in my component (it's a swiper): const styles = EStyleSheet.create({
dotStyle: {
// ... other styles
backgroundColor: '$blue'
}
} and that didn't work. And I tried this way too: const $blue = EStyleSheet.value('$blue') And I get the same error. |
hi @faresite ! console.log('global vars', EStyleSheet.globalVars) Let's see what is in global variables. |
hi @vitalets , what I got was:
|
@Christopher2K thanks for the info! |
I have the same issue too |
@golestanirad could you show a sample code? |
...
|
I get |
@golestanirad // app.js
EStyleSheet.build({
$currencyFontColor: 'hsl(45, 100%, 94%)',
});
const styles = EStyleSheet.create({
underlayColor: Color(EStyleSheet.value('$currencyFontColor')).darken(0.5),
}); It works. But if we change the order: const styles = EStyleSheet.create({
underlayColor: Color(EStyleSheet.value('$currencyFontColor')).darken(0.5),
});
EStyleSheet.build({
$currencyFontColor: 'hsl(45, 100%, 94%)',
}); It throws The solution is to wrap property with const styles = EStyleSheet.create({
underlayColor: () => Color(EStyleSheet.value('$currencyFontColor')).darken(0.5),
});
EStyleSheet.build({
$currencyFontColor: 'hsl(45, 100%, 94%)',
}); |
Hi @vitalets thanks for your help |
@golestanirad could you show more code? Because "model" does not apear in lib sources, it maybe error in other place of your code. |
it doesn't work and gives me the waring:
|
@golestanirad headerTitleStyle: EStyleSheet.create({ // <-- note this
alignSelf: 'center',
borderWidth: 2,
borderColor: 'yellow',
color: () => EStyleSheet.value('$headerTitleColor'),
}), |
Closed as outdated. Feel free to reopen if you need. |
I also want to point this out, for futures devs with the same issue. https://github.com/vitalets/react-native-extended-stylesheet#value
const styles = EStyleSheet.create({
button1: {
width: () => EStyleSheet.value('$contentWidth') + 10 // <-- Correct!
},
button2: {
width: EStyleSheet.value('$contentWidth') + 10 // <-- Incorrect. Because EStyleSheet.build() may occur later and $contentWidth will be undefined at this moment.
}
}); |
@BlaShadow thank you! |
@BlaShadow hi, I am using
is the above wrong to do! and if so, what's the alternative in this case? |
|
Please note that there are certain characters that you shouldn't use in your global variable names such as
After going through the code, I realized that these characters are related to mathematical operations and hence causing an error. Replaced with an
I think its important mentioning this in the README |
Hi,
I'm trying to get all my style values in
EStyleSheet.build({...});
but I'm experiencing some troubles with the error "Unresolved variable: $<VAR_NAME>".Here's my code:
And, the weird thing is that If I remove $RAD, it works with the others values ($ORANGE etc...)
Thank you for your help !
The text was updated successfully, but these errors were encountered: