Matthew Chung
Matthew Chung

Reputation: 1342

mobx observable array flow errors

I'm getting a flow error flow: property replace (Property not found in Array) when I'm calling replace on my array. How do I tell flow it is a mobx observable array? I already made the change to my flowconfig [libs] to include mobx

/* @flow */
import { observable } from 'mobx'

export default class GiphyStore {
  @observable images = []

  async getImageList() {
    try {
      // make axios network request
      const imgs = response.data.data.map(item => {
        return { id: item.id, url: item.images.downsized.url }
      })

      this.images.replace(imgs) // getting error???
    } catch (e) {}
  }
}

Upvotes: 1

Views: 977

Answers (1)

Tukan
Tukan

Reputation: 2333

According to the test file provided by mobx you need to;

  1. Use IObservableArray<> type for your arrays
  2. Define your observable without the decorators as flow does not support them yet.

It was a joint effort of finding the answer, thanks a lot.

Upvotes: 1

Related Questions