D
Size: a a a
D
D
var h = preact.createElement;
var Component = preact.Component;
var render = preact.render;
function Foo(props) {
Component.constructor.call(this);
}
Foo.prototype = Object.create(Component.prototype);
Foo.prototype.render = function() {
return h("div", { style: "color: red", class: "foo" }, [
h("h2", {}, "Foo"),
h(Bar),
h("p", {}, ["props: ", JSON.stringify(this.props)])
]);
};
function Bar(props) {
Component.constructor.call(this);
this.state = {
baz: "baz"
};
}
Bar.prototype = Object.create(Component.prototype);
Bar.prototype.render = function() {
return h(
"p",
{ style: { color: "green", fontFamily: "serif" }, class: "bar" },
[
h("h3", {}, "Bar"),
h("p", {}, ["state: ", JSON.stringify(this.state)])
]
);
};
render(h(Foo, { text: "biz" }), document.body);
S
var h = preact.createElement;
var Component = preact.Component;
var render = preact.render;
function Foo(props) {
Component.constructor.call(this);
}
Foo.prototype = Object.create(Component.prototype);
Foo.prototype.render = function() {
return h("div", { style: "color: red", class: "foo" }, [
h("h2", {}, "Foo"),
h(Bar),
h("p", {}, ["props: ", JSON.stringify(this.props)])
]);
};
function Bar(props) {
Component.constructor.call(this);
this.state = {
baz: "baz"
};
}
Bar.prototype = Object.create(Component.prototype);
Bar.prototype.render = function() {
return h(
"p",
{ style: { color: "green", fontFamily: "serif" }, class: "bar" },
[
h("h3", {}, "Bar"),
h("p", {}, ["state: ", JSON.stringify(this.state)])
]
);
};
render(h(Foo, { text: "biz" }), document.body);
F
TP
TP
D
TP
TP
TP
V
var h = preact.createElement;
var Component = preact.Component;
var render = preact.render;
function Foo(props) {
Component.constructor.call(this);
}
Foo.prototype = Object.create(Component.prototype);
Foo.prototype.render = function() {
return h("div", { style: "color: red", class: "foo" }, [
h("h2", {}, "Foo"),
h(Bar),
h("p", {}, ["props: ", JSON.stringify(this.props)])
]);
};
function Bar(props) {
Component.constructor.call(this);
this.state = {
baz: "baz"
};
}
Bar.prototype = Object.create(Component.prototype);
Bar.prototype.render = function() {
return h(
"p",
{ style: { color: "green", fontFamily: "serif" }, class: "bar" },
[
h("h3", {}, "Bar"),
h("p", {}, ["state: ", JSON.stringify(this.state)])
]
);
};
render(h(Foo, { text: "biz" }), document.body);
import React from ‘react’
export function App () {
return <h1>Привет, ребята</h1>
}
TP
TP