Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot set property 'itx' of undefined #929

Closed
mbranicky opened this issue Mar 27, 2019 · 3 comments
Closed

Uncaught TypeError: Cannot set property 'itx' of undefined #929

mbranicky opened this issue Mar 27, 2019 · 3 comments

Comments

@mbranicky
Copy link

mbranicky commented Mar 27, 2019

Version

5.0.3

Browser and OS info

Chrome 73 / macOS 10.14.3

Steps to reproduce

On the Chrome, it throws an error "Uncaught TypeError: Cannot set property 'itx' of undefined" when I use "registerModule" to dynamically register a nested VUEX module.

Here is our code:

const url = 'static/itx/template-3.itx'
this.$store.registerModule(['designer', `editor${url}`], module)

The position of error code and stack is here:
https://www.dropbox.com/s/kqlahuin84820ay/stacktrace_1.png?dl=0
https://www.dropbox.com/s/howoq8zbrk9da56/stacktrace_2.png?dl=0

What is expected?

The 'object' should not be undefined.

What is actually happening?

Initially the 'object' is the parentState but after the 'while' loop it becomes obviously undefined, because property 'itx' is not a property of parentState.

@blu14x
Copy link

blu14x commented Mar 28, 2019

yep. same here

@mbranicky
Copy link
Author

@znck Working re-producible example: https://3yn2988r01.codesandbox.io/

If you want to see the code: https://codesandbox.io/s/3yn2988r01?fontsize=14

@anisiewicz
Copy link

anisiewicz commented Mar 29, 2019

Problem is with module with state returned form function:

OK

this.$store.registerModule(['bar'], {
      namespaced: true,
      modules: {
        foo: {
          namespaced: true,
          state: {barfoo: 'x'},
          mutations: {
            save (state, v) {
              state.barfoo = v
            },
          }
        }
      },
      state: { bee: 'x'}        
    })
    this.$store.commit(`bar/foo/save`, 'new_content')

NOK:

this.$store.registerModule(['bar'], {
      namespaced: true,
      modules: {
        foo: {
          namespaced: true,
          state: {barfoo: 'x'},
          mutations: {
            save (state, v) {
              state.barfoo = v
            },
          }
        }
      },
      state () {
        return{ bee: 'x'}
      },                
    })
    this.$store.commit(`bar/foo/save`, 'new_content')

Result: state representation in devtools is missing modules.

When I'm trying to load state:

Uncaught TypeError: Cannot set property 'barfoo' of undefined
    at Store.save (App.vue?234e:62)
    at wrappedMutationHandler (vuex.esm.js?2f62:714)
    at mutation.handlers.forEach.handler (backend.js:12126)
    at Array.forEach (<anonymous>)
    at replayMutations (backend.js:12126)
    at Bridge.bridge.on.index (backend.js:12046)
    at Bridge.emit (backend.js:3205)
    at Bridge._emit (backend.js:3028)
    at messages.forEach.message (backend.js:2953)
    at Array.forEach (<anonymous>)

I thinik is realated to #922

Another case, when module has no state defined:

this.$store.registerModule(['bar'], {
      namespaced: true,
      modules: {
        foo: {
          namespaced: true,
          state: {barfoo: 'x'},
          mutations: {
            save (state, v) {
              state.barfoo = v
            },
          }
        }
      },              
    })
    this.$store.commit(`bar/foo/save`, 'new_content')

@Akryum Akryum closed this as completed in 0724381 Apr 14, 2019
sp1ker pushed a commit to sp1ker/vue-devtools that referenced this issue Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants