-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@areslabs/wx-react): 减少对外暴露的接口,相应的增强RNBaseComponent reactCompHel…
…per的能力
- Loading branch information
1 parent
ef72810
commit 6024ce9
Showing
5 changed files
with
72 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import instanceManager from "./InstanceManager"; | ||
|
||
/** | ||
* Copyright (c) Areslabs. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
export default function reactCompHelper(obj) { | ||
obj.properties = { | ||
...obj.properties, | ||
diuu: null, | ||
} | ||
|
||
const rawAttached = obj.attached | ||
obj.attached = function () { | ||
const rawData = this.data | ||
Object.defineProperty(this, 'data', { | ||
get: function () { | ||
const compInst = instanceManager.getCompInstByUUID(rawData.diuu); | ||
return { | ||
...rawData, | ||
...compInst.props | ||
} | ||
}, | ||
}) | ||
rawAttached && rawAttached.call(this) | ||
instanceManager.setWxCompInst(this.data.diuu, this) | ||
} | ||
|
||
const rawDetached = obj.detached | ||
obj.detached = function () { | ||
rawDetached && rawDetached.call(this) | ||
instanceManager.removeUUID(this.data.diuu) | ||
} | ||
|
||
if (!obj.methods) { | ||
obj.methods = {} | ||
} | ||
obj.methods.getReactComp = function () { | ||
return instanceManager.getCompInstByUUID(this.data.diuu) | ||
} | ||
|
||
return obj | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters