-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStaticContainerView.js
More file actions
44 lines (35 loc) · 987 Bytes
/
StaticContainerView.js
File metadata and controls
44 lines (35 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Copyright (c) 2016-present, Lookly
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
import React from 'react';
export default class StaticContainerView extends React.Component {
static propTypes = {
animation: React.PropTypes.object,
renderScene: React.PropTypes.func.isRequired,
renderSceneWrapper: React.PropTypes.func.isRequired,
redrawKey: React.PropTypes.any,
};
constructor(props) {
super(props);
this.privateSymbol = Symbol();
}
componentWillMount() {
this.refresh(this.props);
}
componentWillReceiveProps(nextProps) {
if (nextProps.redrawKey !== this.props.redrawKey) {
this.refresh(nextProps);
}
}
refresh(props) {
this[this.privateSymbol] = props.renderScene();
}
render() {
return this.props.renderSceneWrapper(this[this.privateSymbol], this.props.animation);
}
}