1

When I use the mobx-react ,I use inject decorator to transmit the store.But when I get the store such as

@inject("store") @observer
class item extends Component {
  constructor() {
    this.store = this.props.store;
  }
}

But when I want to call the function of store such as store.getUser() , I found that the context getUser function is not this , how can I bind this to the store ?

PS: the store is such as following :

class Store {
  @observable user = "Sarah";
  @computed
  get getUser() {
    return user + "Ok";
  }
}
export default new Store();

I use the getUser like

render() {
  <div>{this.store.getUser()}</div>
}
4

2 に答える 2