forked from opencomponents/oc-template-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (37 loc) · 1.09 KB
/
app.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
import React from "react";
import {
withDataProvider,
withSettingProvider
} from "oc-template-react-compiler/utils";
import styles, { superSpecial } from "./styles.css";
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
name: props.name
};
}
componentDidMount() {
this.props.getData({ name: "Pippo" }, (err, data) => {
this.setState({ name: data.name });
});
// Don't do this if you don't want to be fired
oc.events.on("oc:componentDidMount", (ev, props) => console.log(props));
}
render() {
const { getSetting } = this.props;
const { name } = this.state;
return (
<div className={styles["just-special"]}>
<h1 className={superSpecial} id="1">
Hello {name}
</h1>
<p>component name: {getSetting("name")}</p>
<p>component version: {getSetting("version")}</p>
<p>registry baseUrl: {getSetting("baseUrl")}</p>
<p>component staticPath: {getSetting("staticPath")}</p>
</div>
);
}
}
export default withSettingProvider(withDataProvider(App));