-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcustom-component-js.js
44 lines (37 loc) · 1.06 KB
/
custom-component-js.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
import React from 'react';
import attach from '../../attach';
import Typography from '@material-ui/core/Typography';
import UIComponent from 'mson/lib/ui-component';
import Form from 'mson/lib/form';
import TextField from 'mson/lib/fields/text-field';
class CustomComponentJS extends UIComponent {
// className is needed as JS minification strips the constructor name
className = 'CustomComponentJS';
create(props) {
super.create(props);
this.set({
schema: new Form({
fields: [
new TextField({
name: 'name',
}),
new TextField({
name: 'label',
}),
],
}),
});
}
}
let ReactCustomComponentJS = (props) => {
const { name, label } = props;
return (
<div>
<Typography variant="h3">Name: {name}</Typography>
<Typography variant="h4">Label: {label}</Typography>
</div>
);
};
// Bind React props to MSON component props
ReactCustomComponentJS = attach(['name', 'label'])(ReactCustomComponentJS);
export { CustomComponentJS, ReactCustomComponentJS };