Skip to content

Commit 0b56326

Browse files
committed
feat(alita): 添加decorators转化支持,添加mobx处理逻辑,添加mobx样例
1 parent 5ee22b0 commit 0b56326

File tree

132 files changed

+9763
-1039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+9763
-1039
lines changed
+52-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,58 @@
1+
function _defineProperty(obj, key, value) {
2+
if (key in obj) {
3+
Object.defineProperty(obj, key, {
4+
value: value,
5+
enumerable: true,
6+
configurable: true,
7+
writable: true
8+
})
9+
} else {
10+
obj[key] = value
11+
}
12+
return obj
13+
}
14+
115
import React, { HocComponent, h } from "@areslabs/wx-react"
216
export default function(WrappedComponent) {
3-
return class Hoc1 extends HocComponent {
4-
state = {
5-
name: "y5g"
6-
}
17+
var _temp
718

8-
componentDidMount() {
9-
console.log("Hoc1 componentDidMount")
10-
}
19+
return (
20+
(_temp = class Hoc1 extends HocComponent {
21+
constructor(...args) {
22+
super(...args)
1123

12-
componentWillUnmount() {
13-
console.log("Hoc1 componentWillUnmount")
14-
}
24+
_defineProperty(this, "state", {
25+
name: "y5g"
26+
})
27+
}
1528

16-
render() {
17-
return React.createElement(WrappedComponent, {
18-
...this.props,
19-
name: this.state.name,
20-
changeName: newName => {
21-
this.setState({
22-
name: newName
23-
})
24-
},
25-
...this.hocProps
26-
})
27-
}
28-
}
29+
componentDidMount() {
30+
console.log("Hoc1 componentDidMount")
31+
}
32+
33+
componentWillUnmount() {
34+
console.log("Hoc1 componentWillUnmount")
35+
}
36+
37+
render() {
38+
return React.createElement(
39+
WrappedComponent,
40+
Object.assign(
41+
{},
42+
this.props,
43+
{
44+
name: this.state.name,
45+
changeName: newName => {
46+
this.setState({
47+
name: newName
48+
})
49+
}
50+
},
51+
this.hocProps
52+
)
53+
)
54+
}
55+
}),
56+
_temp
57+
)
2958
}

examples/HelloWorldExpoWP/src/a/Hoc2.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ export default function(WrappedComponent) {
1010
}
1111

1212
render() {
13-
return React.createElement(WrappedComponent, {
14-
...this.props,
15-
age: "28",
16-
...this.hocProps
17-
})
13+
return React.createElement(
14+
WrappedComponent,
15+
Object.assign(
16+
{},
17+
this.props,
18+
{
19+
age: "28"
20+
},
21+
this.hocProps
22+
)
23+
)
1824
}
1925
}
2026
}

0 commit comments

Comments
 (0)