Skip to content

Added tree properties causing TypeError: Converting circular structure to JSON #64

Open
@al2613

Description

@al2613

I am trying to use JSON.stringify() on the tree data for an app I'm building. The issue is the new generated properties that Drag adds causing converting error. I noticed that there is the pure method that can be used from this post #9 just so that we get raw data. However, the generated properties still seem to be there and the console didn't spit out any error messages. Am I missing something? I'm not sure if perhaps it's because I'm using a computed property (renderList) that grabs data from my store as opposed to local component data?

Template:

<Tree :data="renderList" draggable="draggable" @change="treeChange">
      <div slot-scope="{ data }" class="white --text">
        <template v-if="!data.isDragPlaceHolder">
          <span>{{ data.text }}</span>
          <i class="fas fa-save fa-lg" @click="deleteElement(data._id)"></i>
        </template>
      </div>
    </Tree>
methods: {
    ...mapActions([setClickedElementList]),
    deleteElement(id) {
      //console.log(element);
      this.$store.dispatch(deleteFromComponentHtmlList, id);
    },
    treeChange(node, nodeVm, store) {
      this.renderList = store.pure(store.rootData, true).children
    }
  },
  computed: {
    ...mapState(['componentMap', 'activeComponent']),
    renderList: {
      get() {
        return this.componentMap[this.activeComponent].htmlList;
      },
      set(newArr) {
        console.log('SET', newArr);
        this.setClickedElementList(newArr);
      }
    }
  },

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions