react-native-actionsheet-ex
Version:
Cross platform ActionSheet. This component implements a custom ActionSheet and provides the same way to drawing it on the defferent platforms(iOS and Android). Actually, In order to keep the best effect, it still uses the ActionSheetIOS on iOS. Based on
39 lines (31 loc) • 857 B
JavaScript
/**
* Wrap ActionSheetIOS Api as a component.
* @see http://facebook.github.io/react-native/docs/actionsheetios.html
*/
import React from 'react'
import { ActionSheetIOS } from 'react-native'
import optionsSchema from './options'
class ActionSheet extends React.Component {
// shold not update whenever, because nothing rendered
shouldComponentUpdate () {
return false
}
show (options) {
const props = this.props
if (!options) { options = {} }
optionsSchema.forEach((name) => {
const value = props[name]
if (typeof value !== 'undefined') {
options[name] = value
}
})
const callback = options.onPress
delete options.onPress
ActionSheetIOS.showActionSheetWithOptions(options, callback)
}
// need not render anything
render () {
return null
}
}
export default ActionSheet