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.

I have one doubt can we get the zustand store by id?

Like we access the store using any id.

Explanation:

I want to create a store per component

Let’s say I used a store inside the <Button /> component I’m using the button component many times and the store should create many times also should not share one store for all components. I want to use the first <Button /> store in the second and vice versa using the Id.

I can use context but the problem is I cannot access the store outside the <Button /> component.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dai-shicommented, Jul 6, 2021

There’s no technical drawbacks. It’s not flux-like, so usage drawbacks? Often people complain there’s no way to dispatch an action to multiple stores. It’s true because zustand is not designed so. So, the single store use case is primary. “expert” might be misleading for this one, maybe call it secondary use case.

0reactions
dai-shicommented, Jul 10, 2021
  1. Map<string, Store>
  2. single global store
  3. component store

which one would you like? can you provide a small code snippet to play with?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get Store ID by store code Magento 2
From where you would like to get the store ID: ... You may need to get a current Store ID, Store Code, Name,...
Read more >
Get Store code by Store id programmatically magento 2.
You can get Store code by Store id programmatically using Magento 2. Many times, you have Store id available but you have to...
Read more >
Magento 2 Get Current Store ID, Code, Name, Website ID, URL
Sometimes, during Magento 2 customization you need to get the store Information programmatically. You may need to get a current Store ID, Store...
Read more >
How To Get Current Store ID In Magento 2 - Meetanshi
You can get store ID by calling the block function in your phtml file. ... $objectManager = \Magento\Framework\App\ObjectManager::getInstance();.
Read more >
Magento 2 Get Store ID, Code, Name, infomation in phtml
This article will guide you through how to collect all information of your Magento 2 store including store ID, store name, store URL,...
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