|
|
@@ -29,42 +29,35 @@ export default class Container extends AbstractContainer {
|
|
29
|
29
|
* @returns {ReactElement}
|
|
30
|
30
|
*/
|
|
31
|
31
|
render() {
|
|
32
|
|
- // eslint-disable-next-line prefer-const
|
|
33
|
|
- let { onClick, style, touchFeedback, visible, ...props } = this.props;
|
|
34
|
|
-
|
|
35
|
|
- // onClick & touchFeedback
|
|
36
|
|
- (typeof touchFeedback === 'undefined') && (touchFeedback = onClick);
|
|
|
32
|
+ const {
|
|
|
33
|
+ onClick,
|
|
|
34
|
+ touchFeedback = onClick,
|
|
|
35
|
+ visible = true,
|
|
|
36
|
+ ...props
|
|
|
37
|
+ } = this.props;
|
|
37
|
38
|
|
|
38
|
39
|
// visible
|
|
39
|
|
-
|
|
40
|
|
- // The following property is responsible to hide/show this Container by
|
|
41
|
|
- // setting its size to 0. This will make the component not visible, but
|
|
42
|
|
- // it won't be destroyed, all its state is preserved. This is
|
|
43
|
|
- // intentional.
|
|
44
|
|
- // TODO: replace with display: 'none', supported in RN >= 0.43.
|
|
45
|
|
- const hidden = visible === false; // true / undefined
|
|
46
|
|
-
|
|
47
|
|
- if (hidden) {
|
|
48
|
|
- style = {
|
|
49
|
|
- ...style,
|
|
|
40
|
+ if (!visible) {
|
|
|
41
|
+ // Intentionally hide this Container without destroying it.
|
|
|
42
|
+ // TODO Replace with display: 'none' supported in RN >= 0.43.
|
|
|
43
|
+ props.style = {
|
|
|
44
|
+ ...props.style,
|
|
50
|
45
|
height: 0,
|
|
51
|
46
|
width: 0
|
|
52
|
47
|
};
|
|
53
|
48
|
}
|
|
54
|
49
|
|
|
55
|
|
- // eslint-disable-next-line object-property-newline
|
|
56
|
|
- let component = super._render(View, { ...props, style });
|
|
|
50
|
+ let element = super._render(View, props);
|
|
57
|
51
|
|
|
58
|
|
- if (!hidden && (touchFeedback || onClick)) {
|
|
59
|
|
- const parentType
|
|
60
|
|
- = touchFeedback ? TouchableHighlight : TouchableWithoutFeedback;
|
|
61
|
|
- const parentProps = {};
|
|
62
|
|
-
|
|
63
|
|
- onClick && (parentProps.onPress = onClick);
|
|
64
|
|
-
|
|
65
|
|
- component = React.createElement(parentType, parentProps, component);
|
|
|
52
|
+ // onClick & touchFeedback
|
|
|
53
|
+ if (visible && (onClick || touchFeedback)) {
|
|
|
54
|
+ element = React.createElement(
|
|
|
55
|
+ touchFeedback ? TouchableHighlight : TouchableWithoutFeedback,
|
|
|
56
|
+ { onPress: onClick },
|
|
|
57
|
+ element
|
|
|
58
|
+ );
|
|
66
|
59
|
}
|
|
67
|
60
|
|
|
68
|
|
- return component;
|
|
|
61
|
+ return element;
|
|
69
|
62
|
}
|
|
70
|
63
|
}
|