Guest User

Untitled

a guest
Nov 18th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. ```
  2. import React from 'react'
  3. import { Keyboard } from 'react-native'
  4. import { TabBarBottom } from 'react-navigation'
  5.  
  6. class TabBarComponent extends React.PureComponent {
  7.  
  8. constructor(props) {
  9. super(props)
  10.  
  11. this.keyboardWillShow = this.keyboardWillShow.bind(this)
  12. this.keyboardWillHide = this.keyboardWillHide.bind(this)
  13.  
  14. this.state = {
  15. isVisible: true
  16. }
  17. }
  18.  
  19. componentWillMount() {
  20. this.keyboardWillShowSub = Keyboard.addListener('keyboardDidShow', this.keyboardWillShow)
  21. this.keyboardWillHideSub = Keyboard.addListener('keyboardDidHide', this.keyboardWillHide)
  22. }
  23.  
  24. componentWillUnmount() {
  25. this.keyboardWillShowSub.remove()
  26. this.keyboardWillHideSub.remove()
  27. }
  28.  
  29. keyboardWillShow = event => {
  30. this.setState({
  31. isVisible: false
  32. })
  33. }
  34.  
  35. keyboardWillHide = event => {
  36. this.setState({
  37. isVisible: true
  38. })
  39. }
  40.  
  41. render() {
  42. return this.state.isVisible ?
  43. <TabBarBottom {...this.props} />
  44. :
  45. null
  46. }
  47. }
  48.  
  49. export default TabBarComponent
  50. ```
  51.  
  52. -----------------------------------------------------------------------
  53.  
  54. ```
  55. import TabBarComponent from './TabBarComponent.js'
  56.  
  57. export default TabNavigator({
  58. ...
  59. }, {
  60. initialRouteName: '...',
  61. tabBarComponent: TabBarComponent,
  62. })
  63. ```
Add Comment
Please, Sign In to add comment