question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request for MapWritableState nested object access.

See original GitHub issue

What problem is this solving

Modifying deeply nested properties in the state.

Proposed solution

// Object
...mapWritableState(useStore, {
     myCity: 'form.address.city',
})

// Array ( outputs the latest key as the variable name, in this case city)
...mapWritableState(useStore, ['form.address.city'])

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ferrykranenburgcwcommented, Jun 24, 2022

We have lots of code where we pass the full path to the state and use only the last ‘key’ as the local name. Would love to see this working in Pinia, because it is the only thing holding us back of migrating from Vuex -> Pinia.

0reactions
Bassadincommented, Aug 2, 2022

Is there any update to this? We’d also love to be able to do this or just pass a function like with mapState(). 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I access and process nested objects, arrays, or JSON?
Accessing nested data structures. A nested data structure is an array or object which refers to other arrays or objects, i.e. its values...
Read more >
pinia - Bountysource
The object in the first param in a getter used to be a state. Now (in 0.1.0) it seems to be the ......
Read more >
Accessing Nested Objects in JavaScript - DEV Community ‍ ‍
Access Nested Objects Using Array Reduce. Array reduce method is very powerful and it can be used to safely access nested objects. const ......
Read more >
Accessing Nested Objects in JavaScript - HackerNoon
Oliver Steele's Nested Object Access Pattern. This is my personal favorite as it makes the code look clean and simple. I picked this...
Read more >
Nested field type | Elasticsearch Guide [8.5] | Elastic
Internally, nested objects index each object in the array as a separate hidden document, ... they can only be accessed within the scope...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found