WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@scottmas
Copy link

For those of us coming from a React Native background, having to specify a "default" property on declarations where we don't have any active names is like nails on chalkboard. This is a backwards compatible tweak that makes specifying the "default" property optional when no activeNames are specified. Basically, it allows this:

import ReactCSS from 'reactcss'

const styleObj = {
   logo: {
     color: 'blue'
   },
   header: {
      backgroundColor: 'black'
   } 
}

const styles = ReactCSS(styleObj)

console.log(
  _.isEqual(styleObj, styles) // outputs true
) 

This is far more ergonomic for my use case in which I plan to basically never use activeNames.

Are you okay with this change? It is backwards compatible, but would you prefer maybe a separate named export to expose this functionality? That would also work.

For those of us coming from a React Native background, having to specify a "default" property on every single style declaration is a little like nails on chalkboard. If the user is not specifying any activeNames, it's also completely redundant. Without it, the syntax is almost identical to React Native:

```javascript
import { StyleSheet } from 'react-native' // Basically the sames as `import reactcss from "reactcss"`

const styles = StyleSheet.create({ // Basically the same as `reactcss({...})`
  card: {
     backgroundColor: 'red'
  }
})
```

This is admittedly a syntactic nicety, but it completely backwards compatible and would just be an optional function signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant