-
Notifications
You must be signed in to change notification settings - Fork 1
/
Component.js
64 lines (57 loc) · 1.29 KB
/
Component.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react';
import CSS from 'Core/CSS.helper';
/**
* Nicobar Component
*/
class Component extends React.Component {
/**
* @constructor
* @param {Object} props Component Properties
*/
constructor(props) {
super(props);
this.className = CSS.getClassHash();
}
/**
* @method Component#componentWillReceiveProps(props)
* @description Callback function when Component is receiving new properties
* @private
* @param {Object} props Component Properties
*/
componentWillReceiveProps(props) {
this.reloadStyle(props.style);
}
/**
* @method Component#componentDidMount()
* @description Callback function when Component has been mounted
* @private
*/
componentDidMount() {
this.reloadStyle(this.props.style);
}
/**
* @method Component#reloadStyle(style)
* @private
* @description Reload Nicobar styles
*
* @param {Object} style
*/
reloadStyle(style) {
this.props.nicobarInstance.set(`.${this.className}`, style);
}
/**
* Render
* @method Component#render()
* @description React's Render function
*
* @returns {React.Component} React Component
*/
render() {
return (
<div className={this.className}>
{this.props.children}
</div>
)
}
}
export default Component;