lundi 21 mai 2018

UntrackedPropertyError - Glimmer.js

This is my first time using Glimmer. Its pretty cool and I'm just enjoying using it. That being said, I'm not really sure why but I keep getting an untracked error for the filtered property. I'd really appreciate any advice or help. :)

export default class DoggyAppGlimmer extends Component {
  @tracked dogHouse = [];
  @tracked filterValue = '';

  didInsertElement() {
    fetch('https://dog.ceo/api/breeds/list/all').then((response) => {
        return response.json();
    })
    .then((data) => {
        Object.keys(data.message).map((breed) => {
            fetch(`https://dog.ceo/api/breed/${breed}/images/random`).then((response) => {
                    return response.json();
            })
            .then((image) => {
                    this.dogHouse = [
                        ...this.dogHouse,
                        {
                            breed,
                            image: image.message,
                            filtered: false
                        }
                    ];
            });     
        });
    });
}

filterHandler(e) {
    this.filterValue = e.target.value;
    this.dogHouse = this.dogHouse.map(dog => {
        if (dog.breed.indexOf(this.filterValue) > -1) {
            return Object.assign(dog, {
                filtered: true,
            });
        } else {
            return Object.assign(dog, {
                filtered: false,
            });
        }
    });
    console.log(this.dogHouse);
 }




Aucun commentaire:

Enregistrer un commentaire