Comments (6)
you can do <Text style={styles.['class-name']}>
? while the syntax isn't pretty, it's common way to handle dashes.
@alexmick thoughts?
from react-native-css.
@abeikverdi This project is a community and is open source, we accept pull requests. Can I get a more details, like code examples?
from react-native-css.
Lets say we have a css like this:
.class-name {
attribute1: attribute1;
attribute2: attribute2;
}
The result after using react-native-css would be :
const styles = StyleSheet.create({
'class-name': {
attribute1: 'attribute1';
attribute2: 'attribute2';
}
And after you assign this to an element in React like this example:
<Text style={styles.class-name}>
I assume RN takes class and name as two classes instead of one class and creates an error.
from react-native-css.
I am not sure how this library should convert css classes with dash. Perhaps a class rename?
from react-native-css.
Indeed, the plugin does not rewrite your class names so if you call your class class-name
you have to call it by styles['class-name']
as @sabeurthabti pointed out.
The way around this is to camelCase you classes like so
.className {
attribute1: attribute1;
attribute2: attribute2;
}
Maybe we could force camelCasing of class names but I have a feeling this would be a confusing behaviour...
PS: I edited your comment @abeikverdi to add the quotes around class-name
in the second snippet because this is what react-native-css will output (I just checked)
from react-native-css.
@sabeurthabti Ah I see. Didnt know that I can put the classes inside brackets like that. @alexmick I agree it could be confusing.
Cheers
from react-native-css.
Related Issues (20)
- Can i write LESS like CSS just like that in webpages with this tool? HOT 2
- Doesn't work with Windows OS HOT 1
- value auto is set like null HOT 3
- Can't generate shadowOffset HOT 4
- Shorthands aren't properly expanding HOT 1
- Update purpose and scope HOT 1
- Add validation
- Interest in Integrating? HOT 5
- Convert properties that don't match their CSS equivalent HOT 5
- Compatibility with other css preprocessors - Stylus HOT 1
- nesting styles HOT 9
- Ability to use predefined features from StyleSheet object.
- shadowOpacity
- No Longer under active development.
- [enhancement] Create gulp plugin HOT 2
- Version 2
- V2: package.json points to incorrect main HOT 10
- undefined is not a function (Symbol.iterator) HOT 2
- Unable to use interpolation in CSS HOT 5
- Little hack for code complete to who use VSCode! [suggestion] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-css.