Skip to content

Commit

Permalink
feat(alita): 添加decorators转化支持,添加mobx处理逻辑,添加mobx样例
Browse files Browse the repository at this point in the history
  • Loading branch information
ykforerlang committed Jul 2, 2019
1 parent 5ee22b0 commit 0b56326
Show file tree
Hide file tree
Showing 132 changed files with 9,763 additions and 1,039 deletions.
75 changes: 52 additions & 23 deletions examples/HelloWorldExpoWP/src/a/Hoc1.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,58 @@
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
})
} else {
obj[key] = value
}
return obj
}

import React, { HocComponent, h } from "@areslabs/wx-react"
export default function(WrappedComponent) {
return class Hoc1 extends HocComponent {
state = {
name: "y5g"
}
var _temp

componentDidMount() {
console.log("Hoc1 componentDidMount")
}
return (
(_temp = class Hoc1 extends HocComponent {
constructor(...args) {
super(...args)

componentWillUnmount() {
console.log("Hoc1 componentWillUnmount")
}
_defineProperty(this, "state", {
name: "y5g"
})
}

render() {
return React.createElement(WrappedComponent, {
...this.props,
name: this.state.name,
changeName: newName => {
this.setState({
name: newName
})
},
...this.hocProps
})
}
}
componentDidMount() {
console.log("Hoc1 componentDidMount")
}

componentWillUnmount() {
console.log("Hoc1 componentWillUnmount")
}

render() {
return React.createElement(
WrappedComponent,
Object.assign(
{},
this.props,
{
name: this.state.name,
changeName: newName => {
this.setState({
name: newName
})
}
},
this.hocProps
)
)
}
}),
_temp
)
}
16 changes: 11 additions & 5 deletions examples/HelloWorldExpoWP/src/a/Hoc2.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ export default function(WrappedComponent) {
}

render() {
return React.createElement(WrappedComponent, {
...this.props,
age: "28",
...this.hocProps
})
return React.createElement(
WrappedComponent,
Object.assign(
{},
this.props,
{
age: "28"
},
this.hocProps
)
)
}
}
}
Loading

0 comments on commit 0b56326

Please sign in to comment.