feat: simpleify code

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-07-30 18:52:22 +08:00
parent 9de6a1eb36
commit d66c64fdff
3 changed files with 8 additions and 7 deletions

View File

@ -1,6 +1,5 @@
let mapDefaultProps = ({ def }) => ({ ...def })
let mapDefaultProps = (obj: any) => ((def) => ({ ...def[obj.name.toLowerCase()] }))
export {
mapDefaultProps
}

View File

@ -9,8 +9,8 @@ import { mapDefaultProps } from '../../models/utils';
import './index.scss';
import { IndexProps, IndexState } from './type';
@connect(mapDefaultProps)
export default class Index extends Component<IndexProps, IndexState> {
@connect(mapDefaultProps(Index))
class Index extends Component<IndexProps, IndexState> {
config: Config = {
navigationBarTitleText: '首页',
enablePullDownRefresh: true
@ -55,3 +55,5 @@ export default class Index extends Component<IndexProps, IndexState> {
)
}
}
export default Index

View File

@ -10,8 +10,8 @@ import defaultImage from '../../assets/images/logo.png';
import './index.scss';
import { MyIndexProps, MyState } from './type';
@connect(mapDefaultProps)
class Index extends Component<MyIndexProps, MyState> {
@connect(mapDefaultProps(My))
class My extends Component<MyIndexProps, MyState> {
config: Config = {
navigationBarTitleText: '个人中心',
enablePullDownRefresh: true
@ -103,4 +103,4 @@ class Index extends Component<MyIndexProps, MyState> {
}
}
export default Index
export default My