浏览代码

ref(local-video): merge styles at render

Remove caching of calculated styles, thereby removing
componentWillReceiveProps, by passing in base styles
and passed in styles when rendering.
master
Leonard Kim 6 年前
父节点
当前提交
35da17f5a6
共有 1 个文件被更改,包括 6 次插入60 次删除
  1. 6
    60
      react/features/welcome/components/LocalVideoTrackUnderlay.native.js

+ 6
- 60
react/features/welcome/components/LocalVideoTrackUnderlay.native.js 查看文件

33
     style: Object
33
     style: Object
34
 };
34
 };
35
 
35
 
36
-/**
37
- * The type of the React {@code Component} state of
38
- * {@link LocalVideoTrackUnderlay}.
39
- */
40
-type State = {
41
-
42
-    /**
43
-     * The style of {@code LocalVideoTrackUnderlay} which is a combination
44
-     * of its default style and the consumer-specified style.
45
-     */
46
-    style: Object
47
-};
48
-
49
 /**
36
 /**
50
  * Implements a React {@code Component} which underlays the local video track,
37
  * Implements a React {@code Component} which underlays the local video track,
51
  * if any, underneath its children.
38
  * if any, underneath its children.
52
  */
39
  */
53
-class LocalVideoTrackUnderlay extends Component<Props, State> {
54
-    /**
55
-     * Initializes a new {@code LocalVideoTrackUnderlay} instance.
56
-     *
57
-     * @param {Object} props - The read-only React {@code Component} props with
58
-     * which the new instance is to be initialized.
59
-     */
60
-    constructor(props) {
61
-        super(props);
62
-
63
-        this.componentWillReceiveProps(props);
64
-    }
65
-
66
-    /**
67
-     * Notifies this mounted React {@code Component} that it will receive new
68
-     * props. Forks (in Facebook/React speak) the prop {@code style} because its
69
-     * value is to be combined with the default style.
70
-     *
71
-     * @inheritdoc
72
-     * @param {Object} nextProps - The read-only React {@code Component} props
73
-     * that this instance will receive.
74
-     * @returns {void}
75
-     */
76
-    componentWillReceiveProps(nextProps) {
77
-        // style
78
-        const prevStyle = this.props && this.props.style;
79
-        const nextStyle = nextProps && nextProps.style;
80
-        const assignState = !this.state;
81
-
82
-        if (prevStyle !== nextStyle || assignState) {
83
-            const nextState = {
84
-                style: {
85
-                    ...styles.localVideoTrackUnderlay,
86
-                    ...nextStyle
87
-                }
88
-            };
89
-
90
-            if (assignState) {
91
-                // eslint-disable-next-line react/no-direct-mutation-state
92
-                this.state = nextState;
93
-            } else {
94
-                this.setState(nextState);
95
-            }
96
-        }
97
-    }
98
-
40
+class LocalVideoTrackUnderlay extends Component<Props> {
99
     /**
41
     /**
100
      * Implements React's {@link Component#render()}.
42
      * Implements React's {@link Component#render()}.
101
      *
43
      *
105
      */
47
      */
106
     render() {
48
     render() {
107
         return (
49
         return (
108
-            <View style = { this.state.style }>
50
+            <View
51
+                style = { [
52
+                    styles.localVideoTrackUnderlay,
53
+                    this.props.style
54
+                ] }>
109
                 <VideoTrack videoTrack = { this.props._localVideoTrack } />
55
                 <VideoTrack videoTrack = { this.props._localVideoTrack } />
110
                 <TintedView>
56
                 <TintedView>
111
                     { this.props.children }
57
                     { this.props.children }

正在加载...
取消
保存