Skip to content

Commit

Permalink
fix(transformer): 自定义组件 ID 未生成
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Apr 25, 2019
1 parent db939e7 commit f29bc9d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/taro-transformer-wx/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,9 @@ export class RenderParser {
})
}
this.handleLoopComponents()
if (Adapter.type === Adapters.weapp || Adapter.type === Adapters.swan || Adapter.type === Adapters.tt) this.handleComponents(renderBody)
if (Adapter.type === Adapters.weapp || Adapter.type === Adapters.swan || Adapter.type === Adapters.tt) {
this.handleComponents(renderBody)
}
renderBody.traverse(this.visitors)
if (Adapter.type === Adapters.quickapp) {
renderBody.traverse(this.quickappVistor)
Expand Down Expand Up @@ -1866,7 +1868,7 @@ export class RenderParser {
body.push(returnStatement)
} else {
body.push(returnStatement)
const stateName = 'loopArray' + this.loopArrayId()
const stateName = this.loopComponentNames.get(callee) as string
// setJSXAttr(returned, Adapter.for, t.identifier(stateName))
this.addRefIdentifier(callee, t.identifier(stateName))
// this.referencedIdentifiers.add(t.identifier(stateName))
Expand Down Expand Up @@ -2119,7 +2121,12 @@ export class RenderParser {
)
)
if (this.isDefaultRender) {
const propsStatement: t.ExpressionStatement | t.VariableDeclaration[] = [...this.propsSettingExpressions].map(expr => {
if (typeof expr === 'function') return expr()
return expr
})
this.renderPath.node.body.body = this.renderPath.node.body.body.concat(
...propsStatement,
buildAssignState(pendingState),
t.returnStatement(
t.memberExpression(t.thisExpression(), t.identifier('state'))
Expand Down

0 comments on commit f29bc9d

Please sign in to comment.