I have a function that maps text to letters:
sizeToLetterMap: function() {
return {
small_square: \'s\',
large_square: \'q\
If you want to keep the constants in the React component, use statics
property, like the example below. Otherwise, use the answer given by @Jim
var MyComponent = React.createClass({
statics: {
sizeToLetterMap: {
small_square: 's',
large_square: 'q',
thumbnail: 't',
small_240: 'm',
small_320: 'n',
medium_640: 'z',
medium_800: 'c',
large_1024: 'b',
large_1600: 'h',
large_2048: 'k',
original: 'o'
},
someOtherStatic: 100
},
photoUrl: function (image, size_text) {
var size = MyComponent.sizeToLetterMap[size_text];
}