Skip to content

Commit

Permalink
fix(transformer): 在 JSX 中用到源于 this.state 的对象没有加入 usedState,close #1492
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Dec 17, 2018
1 parent a2ca3b9 commit 9bec112
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ ruleTester.run('no-jsx-in-class-method', rule, {
}
return <View />
})`
]),
]).com,
invalid: testInvalid(ERROR_MESSAGE, [
`
class App extends Component {
_render() {
return <View />
test(a) {
return a.map(_ => <View />)
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-transformer-wx/src/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class Transformer {
const sibling = path.getSibling('property')
if (
path.get('object').isThisExpression() &&
path.get('property').isIdentifier({ name: 'props' }) &&
(path.get('property').isIdentifier({ name: 'props' }) || path.get('property').isIdentifier({ name: 'state' })) &&
sibling.isIdentifier()
) {
const attr = path.findParent(p => p.isJSXAttribute()) as NodePath<t.JSXAttribute>
Expand Down

0 comments on commit 9bec112

Please sign in to comment.