facebook/react — pull request #1754 by sebmak (2014-06-27 17:39:13+00:00)
Title: Added option to define a fallback class in case all values return false.

I ran into the problem when building a drag and drop file uploader where i was detecting filetype and displaying a specific font-awesome icon.

the code before was something like:

```javascript

var image = new RegExp("image/");
image = image.test(items[i].type);
var text = new RegExp("text/");
text = text.test(items[i].type);
var pdf = new RegExp("/pdf");
pdf = pdf.test(items[i].type);

var classes=cx({
'fa-file-image-o':image,
'fa-file-text-o':text,
'fa-file-pdf-o':pdf,
'fa fa-fw':true,
'fa-file-o':!image && !text && !pdf
})
```

This in my opinion made it more difficult to add new file types than it needed to be. so my solution was to come up with a way to add a fallback in case something returned false, while not breaking the code where i used cx() earlier. This in my opinion is a much better way to do it. My code to set the classes now looks like below giving me easier control without any real noticeable performance loss.

```javascript
var image = new RegExp("image/");
var text = new RegExp("text/");
var pdf = new RegExp("/pdf");

var classes=cx({
'fa fa-fw fa-file-image-o':image.test(items[i].type),
'fa fa-fw fa-file-text-o':text.test(items[i].type),
'fa fa-fw fa-file-pdf-o':pdf.test(items[i].type),
},'fa fa-fw fa-file-o')

```