{"action":"created","issue":{"url":"https://api.github.com/repos/vuejs/vue/issues/4556","repository_url":"https://api.github.com/repos/vuejs/vue","labels_url":"https://api.github.com/repos/vuejs/vue/issues/4556/labels{/name}","comments_url":"https://api.github.com/repos/vuejs/vue/issues/4556/comments","events_url":"https://api.github.com/repos/vuejs/vue/issues/4556/events","html_url":"https://github.com/vuejs/vue/issues/4556","id":197367469,"number":4556,"title":"[Vue 2.0] [Vuex] Cannot create property mergeHook on string 'beforeCreate' ","user":{"login":"jessereitsma","id":5758900,"avatar_url":"https://avatars.githubusercontent.com/u/5758900?v=3","gravatar_id":"","url":"https://api.github.com/users/jessereitsma","html_url":"https://github.com/jessereitsma","followers_url":"https://api.github.com/users/jessereitsma/followers","following_url":"https://api.github.com/users/jessereitsma/following{/other_user}","gists_url":"https://api.github.com/users/jessereitsma/gists{/gist_id}","starred_url":"https://api.github.com/users/jessereitsma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessereitsma/subscriptions","organizations_url":"https://api.github.com/users/jessereitsma/orgs","repos_url":"https://api.github.com/users/jessereitsma/repos","events_url":"https://api.github.com/users/jessereitsma/events{/privacy}","received_events_url":"https://api.github.com/users/jessereitsma/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-23T13:13:34Z","updated_at":"2016-12-23T14:15:17Z","closed_at":"2016-12-23T14:15:17Z","body":"This issue is kinda the same as #4544, but i've got it working now.\r\n\r\nWhen you have (multiple) components in components, and they all use `store` (`vuex`) in the following way:\r\n```\r\nimport storeName from 'storeFile'\r\n\r\nexport default {\r\n  store: storeName,\r\n  methods: {\r\n    // your methods\r\n  }\r\n}\r\n```\r\n\r\nit will result in an error some times (not always) and only in Chrome (on my computer, not on my colleagues computer with same browser, etc), not in Safari. (Mac OS X Yosemite)\r\n\r\nError:\r\n```\r\nTypeError: Cannot create property 'function mergeHook(\r\n  parentVal,\r\n  childVal\r\n) {\r\n  return childVal\r\n    ? parentVal\r\n      ? parentVal.concat(childVal)\r\n      : Array.isArray(childVal)\r\n        ? childVal\r\n        : [childVal]\r\n    : parentVal\r\n}' on string 'beforeCreate'\r\n    at mergeField (eval at <anonymous> (app.js:606), <anonymous>:1169:18)\r\n    at mergeOptions (eval at <anonymous> (app.js:606), <anonymous>:1160:5)\r\n    at resolveConstructorOptions (eval at <anonymous> (app.js:606), <anonymous>:3329:32)\r\n    at createComponent (eval at <anonymous> (app.js:606), <anonymous>:2391:3)\r\n    at _createElement (eval at <anonymous> (app.js:606), <anonymous>:2864:15)\r\n    at Proxy.render (eval at <anonymous> (app.js:3090), <anonymous>:91:7)\r\n    at VueComponent.Vue._render (eval at <anonymous> (app.js:606), <anonymous>:2954:22)\r\n    at VueComponent.eval (eval at <anonymous> (app.js:606), <anonymous>:2191:21)\r\n    at Watcher.get (eval at <anonymous> (app.js:606), <anonymous>:1656:27)\r\n    at new Watcher (eval at <anonymous> (app.js:606), <anonymous>:1648:12)\r\n```\r\n\r\nI think it is trying to \"merge\" (`mergeHook` (?)) the property's (including `store`) with his parent component.\r\n\r\nI'm not 100% sure that this is the issue, but I have changed every `store: storeName` to the data:\r\n```\r\nexport default {\r\n  data () {\r\n    return {\r\n      'store': storeName\r\n    };\r\n  },\r\n\r\n  methods: {\r\n  }\r\n}\r\n```\r\n\r\nAnd everything works now. But when I change everything back to `store: storeName` (property on the same level as `data`, `methods`, `computed`, etc.. it will throw the error again.\r\n\r\nI hope this is helpfull, and if people have the same issue they should try this to solve it."},"comment":{"url":"https://api.github.com/repos/vuejs/vue/issues/comments/268995977","html_url":"https://github.com/vuejs/vue/issues/4556#issuecomment-268995977","issue_url":"https://api.github.com/repos/vuejs/vue/issues/4556","id":268995977,"user":{"login":"posva","id":664177,"avatar_url":"https://avatars.githubusercontent.com/u/664177?v=3","gravatar_id":"","url":"https://api.github.com/users/posva","html_url":"https://github.com/posva","followers_url":"https://api.github.com/users/posva/followers","following_url":"https://api.github.com/users/posva/following{/other_user}","gists_url":"https://api.github.com/users/posva/gists{/gist_id}","starred_url":"https://api.github.com/users/posva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/posva/subscriptions","organizations_url":"https://api.github.com/users/posva/orgs","repos_url":"https://api.github.com/users/posva/repos","events_url":"https://api.github.com/users/posva/events{/privacy}","received_events_url":"https://api.github.com/users/posva/received_events","type":"User","site_admin":false},"created_at":"2016-12-23T14:15:17Z","updated_at":"2016-12-23T14:15:17Z","body":"Closing since you shouldn't be using it that way, but I still want to know how you ended up passing the store to all the components 🙂 "}}
{"actor":{"display_login":"posva"}}