forked from reactive-python/reactpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallable-prop.js
More file actions
26 lines (23 loc) · 735 Bytes
/
callable-prop.js
File metadata and controls
26 lines (23 loc) · 735 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
import { h, render } from "https://unpkg.com/preact?module";
import htm from "https://unpkg.com/htm?module";
const html = htm.bind(h);
export function bind(node, config) {
return {
create: (type, props, children) => h(type, props, ...children),
render: (element) => render(element, node),
unmount: () => render(null, node),
};
}
// The intention here is that Child components are passed in here so we check that the
// children of "the-parent" are "child-1" through "child-N"
export function Component(props) {
var text = "DEFAULT";
if (props.setText && typeof props.setText === "function") {
text = props.setText("PREFIX TEXT: ");
}
return html`
<div id="${props.id}">
${text}
</div>
`;
}