mariocasciaro / object-path-immutable

Modify deep object properties without modifying the original object (immutability). Works great with React and Redux.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using this in Nuxt/Vuex setup - Error - import: export 'default' (imported as 'immutable') was not found in 'object-path-immutable'

malkhuzayyim opened this issue · comments

In package json:

  "dependencies": {
    "@nuxtjs/axios": "^5.3.6",
    "cross-env": "^5.2.0",
    "express": "^4.16.4",
    "nuxt": "^2.0.0",
    "object-path-immutable": "^4.1.0"
  },

Importing it like this:
import immutable from "object-path-immutable";

Using it in a vuex mutation like this:

const mutations = {
  updateComponent: (state, { treePath = [], updatedComponent = {} }) => {
    state.componentTree = immutable.update(
      state.componentTree,
      treePath.join(".children."),
      updatedComponent
    );
    return state;
  }
};

Not sure if I'm doing anything wrong, cant find much about using this in this particular setup. Simply followed the docs to get started and I can't seem to overcome this yet.

Tried destructuring it to get the "update" function, tried es5 imports using require, neither worked with varying errors.

With the es5 imports, the error message was something like: TypeError: updater is not a function at update (object-path-immutable.js?bfd9:138)

Also tried to transpile it in the nuxt config: transpile: [/^vuetify/, /^object-path-immutable/], with es5/es6 imports, neither worked

nevermind, i was just using the update function wrong

works now with es5 import/destructured import, default still doesn't work though, closing the issue anyway

thank you