Skip to content

Commit

Permalink
chore: stateless
Browse files Browse the repository at this point in the history
  • Loading branch information
Foveluy committed Apr 27, 2018
1 parent 32c77ce commit e559cdc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
- [x] 页面内组件引入无状态组件
- [ ] wxs支持
- [x] 页面内箭头函数无状态组件
- [ ] 无状态组件的属性设置问题
- [x] 无状态组件的属性设置问题
- [ ] 组件间通信
- [x] 状态管理
- [x] redux
Expand Down
2 changes: 1 addition & 1 deletion docs/stateless.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Demo extends Page {
return (
<view>
<First data="{{foo}}" />
<First data="{{bar:'我是bar'}}" >
<First data="{{bar:'我是bar'}}" />
</view>
)
}
Expand Down
7 changes: 6 additions & 1 deletion lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,12 @@ const ConvertStyle = node => {
const ConverJSXExpressionContainer = (path, isTemplate) => {
if (t.isJSXAttribute(path.parent)) {
if (isTemplate) {
logger.warn(' 在小程序中,无状态组件的使用方式为:<Stateless data="{{ foo:1, bar:2 }}"/> \n更多详情:')
if (path.parent.name.name !== 'data') {
logger.warn(
' 在小程序中,无状态组件的使用方式为:<Stateless data="{{ foo:1, bar:2 }}"/> 更多详情:\n\
https://github.com/215566435/react-wechat/blob/master/docs/stateless.md'
)
}
}
path.replaceWith(t.stringLiteral(`{{${generate(path.node.expression).code}}}`))
return
Expand Down

0 comments on commit e559cdc

Please sign in to comment.