react-native-actionsheet
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.
37 lines (31 loc) • 836 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 () {
const props = this.props
const 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