Skip to content

Commit

Permalink
chore: 完善mobx样例
Browse files Browse the repository at this point in the history
  • Loading branch information
ykforerlang committed Jul 2, 2019
1 parent bc3ccd1 commit 31a1846
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
3 changes: 0 additions & 3 deletions examples/RoomMobx/src/components/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import {observer} from 'mobx-react'
@observer
class Room extends Component {


render() {
const {style, data, autoFocus} = this.props
console.log('data:', data)
return (
<View style={style}>
<Text>{data.label}</Text>
Expand All @@ -25,7 +23,6 @@ class Room extends Component {
value={data.price + ''}
style={{borderBottomWidth: 2, width: 40}}
onChangeText={(price) => {
console.log('price:', price)
data.price = Number(price)
}}
/>
Expand Down
9 changes: 7 additions & 2 deletions examples/RoomMobx/src/components/TotalInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import React, {Component} from 'react'
import {View, Text, StyleSheet} from 'react-native'
import {inject, observer} from 'mobx-react'

@inject('room')
/*演示inject接收函数的时候*/
@inject((allStores) => {
return {
...allStores.room
}
})
@observer
export default class TotalInfo extends Component {

render() {
const {bedRoom1, bedRoom2, kitchen, bookroom, total} = this.props.room
const {bedRoom1, bedRoom2, kitchen, bookroom, total} = this.props

return (
<View>
Expand Down
8 changes: 4 additions & 4 deletions examples/RoomMobxWP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "RoomMobx",
"version": "0.0.1",
"dependencies": {
"@areslabs/wx-router": "beta",
"@areslabs/wx-router": "^1.0.0",
"@areslabs/wx-mobx": "^1.0.0",
"@areslabs/wx-mobx-react": "0.0.3",
"@areslabs/wx-react": "beta",
"@areslabs/wx-mobx-react": "^1.0.0",
"@areslabs/wx-react": "^1.0.0",
"@areslabs/wx-react-native": "^1.0.0"
}
}
}
2 changes: 0 additions & 2 deletions examples/RoomMobxWP/src/components/Room.comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ let Room =

render() {
const { style, data, autoFocus } = this.props
console.log("data:", data)
return h(
"block",
{
Expand Down Expand Up @@ -46,7 +45,6 @@ let Room =
width: 40
},
onChangeText: price => {
console.log("price:", price)
data.price = Number(price)
},
diuu: "DIUU00003"
Expand Down
6 changes: 4 additions & 2 deletions examples/RoomMobxWP/src/components/TotalInfo.comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ var _dec, _class, _temp
import React, { Component, h } from "@areslabs/wx-react"
import { View, Text } from "@areslabs/wx-react-native"
import { inject, observer } from "@areslabs/wx-mobx-react"
let TotalInfo = ((_dec = inject("room")),
let TotalInfo = ((_dec = inject(allStores => {
return Object.assign({}, allStores.room)
})),
_dec(
(_class =
observer(
Expand All @@ -20,7 +22,7 @@ _dec(
kitchen,
bookroom,
total
} = this.props.room
} = this.props
return h(
"block",
{
Expand Down

0 comments on commit 31a1846

Please sign in to comment.