Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set array of data into mobx array show proxy objects

I'm using react js with mobx and I get data from api. the data I get is array of objects. when I set the data into mobx variable then I see array of proxy objects(not sure what the proxy says). I'm trying just to set the array of objects I get from api into mobx variable.

my store

class UserStore {
@persist @observable token = null
@observable tasks = []
@observable done = false

@persist @observable email = ''

constructor() {

}
@action
getTasks = async () => {
    try {
        let response = await Api.getTasks()
        console.log('getTasks',response.tasks)
        this.tasks = response.tasks
        console.log('my new tasks',this.tasks)

    } catch (e) {
        console.log(e)
    }
}

enter image description here

as you can see here in the first block('black') the data i get from api, then i set the respnse.tasks into this.tasks.

 this.tasks = response.tasks
  console.log('my new tasks',this.tasks)
like image 507
Manspof Avatar asked Jul 30 '18 14:07

Manspof


1 Answers

You can convert proxy to JS:

import { toJS } from 'mobx'

// example
toJS(response)
like image 194
Tarun konda Avatar answered Sep 21 '22 21:09

Tarun konda