TypeError: this.refEditor.get(...) is undefined. Editing Pinia state on component causes error.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 279
- PR merge metrics
- No merged PRs in 30d
Description
Environment
- OS: Windows
- NPM: 11.4.1
- Vue.js devtools: 7.7.7
- vue: 3.5.16
- pinia: 3.0.3
- Browsers: Firefox, Chrome
Description
There is a bug pertaining to either Vue.js devtools or Pinia that is observable in devtools v7 but not v6.
Expected behavior
Typically, when a Pinia store is loaded, you can select a component on the page and see a section on the right pertaining to props, setup data, and the Pinia store. Devtools lets you edit the Pinia state from this view:
Actual behavior
When trying to edit the Pinia state from this view in Firefox, an error appears reporting: TypeError: this.refEditor.get(...) is undefined:
The same error happens in Chrome, but instead it shows the name of the actual state property:
The reason why one of the screenshots shows an edited count is because editing Pinia state from the Pinia tab instead of the Components tab results in the expected behavior where there is no issue editing the Pinia state.
Reproduction steps
Fortunately this is easy to reproduce:
- Create a new project with
npm create vue@latest - Add Pinia to the project
- This will add a
counter.jsstore by default
- This will add a
- In
src/components/HelloWorld.vue, optionally add the following to show the count on the page:<script setup> import { useCounterStore } from '../stores/counter' const counterStore = useCounterStore() ... </script> ... <div class="greetings"> <p style="font-size: 4em"> The count: {{ counterStore.count }}</p> ... - Run
npm installandnpm run dev - Visit the site and try editing the Pinia store, such as by incrementing/decrementing the
countstate, from both the Pinia tab, which should be successful, and from the HelloWorld component in the Components tab, which should result in the error.
More Details
The browser is saying the error happens in prepare.js. Here is the prettified version of the place where the error happens:
I could be wrong, but after doing some investigating, I strongly suspect this is referring to https://github.com/vuejs/devtools/blob/07a637aa7fc70062d586bacd2176e6a65d449a10/packages/devtools-kit/src/core/component/state/editor.ts#L33
Thank you very much for any assistance.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the Vue starter project and Pinia, comparing edits from the Pinia tab with edits in the Components tab. Then inspect packages/devtools-kit/src/core/component/state/editor.ts around the suspected refEditor lookup. Done means editing Pinia state from the Components tab works in both Firefox and Chrome without the TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100