-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Component-specific Store not inherited by child components. #1538
Comments
This is because of this line. We'll need to find some other way to grab the store from the parent instead of from the root. |
I think it would be great if we'll have reference to the parent component |
This will be a breaking change for those of us who rely on this behaviour. Maybe we need a way to explicitly specify which store to use rather than changing the default behaviour of using the root store. |
@ekhaled Seems, the current behavior is not described in docs and even @Rich-Harris thought that it's working with inheritance in the subtree. Moreover, the current behavior leads to uncontrolled consequences of using component-specific stores. |
I think @Rich-Harris means to find a way to have both stores available. |
@ekhaled Yep, but it will bring more complexity to store itself and how we use it. I don't think that there 're many cases where we actually need to have direct access to the stores through all hierarchy of components. But if so, what if you'll want to get access to the store of a parent of a parent of your component? Actually, even right now each component in the tree can get direct access to root-store using |
When I use, for example, As long as I can be sure that this key has not been tainted somewhere in the hierarchy by a component with an alternative store, I'll be happy. |
@ekhaled You will be sure in that case, too. There are 3 ways to put some component in components tree:
<Child />
<script>
import Child from './Child.html'
export default {
components: { Child }
};
</script>
<Parent>
<Child />
</Parent>
<script>
import Child from './Child.html'
export default {
components: { Child }
};
</script>
<Parent {Child} />
<script>
import Child from './Child.html'
export default {
data: {
return { Child };
}
};
</script> So, only in first variant your |
@Rich-Harris Any updates here? Sorry for my intrusiveness, but we use Svelte in the real project for our customer and seems this issue already blocks our progress a little. Maybe we could implement a solution you describe in #1539 ? |
Fixed in 2.8.0 |
REPL
SubChild
should use parent store instead of root store.The text was updated successfully, but these errors were encountered: