You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Container.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // @flow
  2. import React from 'react';
  3. import {
  4. TouchableHighlight,
  5. TouchableWithoutFeedback,
  6. View
  7. } from 'react-native';
  8. import AbstractContainer from '../AbstractContainer';
  9. /**
  10. * Represents a container of React Native/mobile {@link Component} children.
  11. *
  12. * @extends AbstractContainer
  13. */
  14. export default class Container extends AbstractContainer {
  15. /**
  16. * {@code Container} component's property types.
  17. *
  18. * @static
  19. */
  20. static propTypes = AbstractContainer.propTypes;
  21. /**
  22. * Implements React's {@link Component#render()}.
  23. *
  24. * @inheritdoc
  25. * @returns {ReactElement}
  26. */
  27. render() {
  28. const {
  29. onClick,
  30. touchFeedback = onClick,
  31. visible = true,
  32. ...props
  33. } = this.props;
  34. // visible
  35. if (!visible) {
  36. return null;
  37. }
  38. let element = super._render(View, props);
  39. // onClick & touchFeedback
  40. if (element && (onClick || touchFeedback)) {
  41. element
  42. = React.createElement(
  43. touchFeedback
  44. ? TouchableHighlight
  45. : TouchableWithoutFeedback,
  46. { onPress: onClick },
  47. element);
  48. }
  49. return element;
  50. }
  51. }