Add PropType 'object' to options
Currently only accept array. but some examples are use object
So i add object of PropTypes
have you tested object options. Not sure ListView datasource can accept it.
@sohobloo Oops!! Sorry to late.
Yes, we are already use it.
I did check with official document about this, but i could not found.
But fortunately i found example code. https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/RNTester/js/SwipeableListViewExample.js#L90 this code also use Hash
I will explain to you more In my case
render() {
...
return (
<ModalDropdown
dropdownStyle={Styles.toolbarDropdown}
dropdownTextStyle={Styles.toolbarSortLabel}
animated={false}
options={this.sortItems}
onSelect={this.setSort}
>
<View style={Styles.toolbarSortWrapper}>
<Text style={Styles.toolbarSortLabel}>{t(`products.sort.${sort}`)}</Text>
<Icon name="dropdown" style={Styles.toolbarSortIcon} />
</View>
</ModalDropdown>
)
}
get sortItems() {
const t = this.props.translate
const keys = ['recent',
'lower_deposit', 'higher_deposit',
'lower_amount', 'higher_amount',
]
const hash = {}
keys.forEach((key) => {
hash[key] = t(`products.sort.${key}`)
})
return hash
}
setSort(sort) {
if (this.state.sort !== sort) {
const params = { ...this.state.params, sort, page: 1 }
this.setState({ sort, page: 1, params })
this.fetch(params)
}
}
I did translate for sort options, this mean is sort values are change when users are change language
For example, if you use English then value is 'recent', but if you change to Korea then value is change to '최신순'
So we use Hash, you known just use hash key is good and better in this case