reactcss icon indicating copy to clipboard operation
reactcss copied to clipboard

Optional default property

Open scottmas opened this issue 7 years ago • 0 comments

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.

scottmas avatar Dec 21 '18 22:12 scottmas