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
Hi Support AlpineJS V3 alpine-collective..? #140
Comments
We've been talking about creating a new repo for v3 items and leave this one locked to V2. What helpers are you using? |
Yes good idea, I just wanted to know if it was compatible with the new version AlpineJS V3. At the moment I continue with the V2, but I will see to migrate to the V3 little by little. |
Just to put my 2 cents in. I usually come and grab the |
The component helper would be replaced by There could be extreme edge cases where both would be useful though still, like if you need to access a parent prop that has the same name as the child component (maybe you can't control the incoming data), but not sure that's something anyone will use. |
The one I've been using is the $scroll helper. I made a quick version of it using the new v3 Alpine.magic which works without the smooth scroll polyfill. Should be easy enough to include the polyfill, though I've had other pressing dev concerns. It would be great if you roll out a new v3 of the helpers as the $fetch one I'd like to use in another project. |
I think |
I think with stores/reusable components,
|
I would really appreciate if someone could help me understand how to replace |
that's probably the way to do it 😄 but it is now more hacky because there's now scopes that stack (for child to read/modify parent scope) and stores (for siblings components) |
@HugoDF That's why a |
You would put all the logic from component B into the store, then from component A and B you would use the store to access it. Putting it in the store allows you to access it from anywhere essentially. It's not a drop in replacement for But here you go Alpine.magic('component', (el, { Alpine: { closestRoot } }) => {
return (selector) => {
const root = closestRoot(document.querySelector(selector))
return root._x_dataStack[0]
}
}) https://codepen.io/KevinBatdorf/pen/GRmJbNq?editors=1010 it's essentially what you are doing now, but has an extra check you're on the root (simply because the check was already in my clipboard 😎) It doesn't have the added checks |
@KevinBatdorf Thanks! 🙇♂️ I will use your snippet of code for now as I'm just trying to migrate to v3 without any regressions (so far so good!). But I do understand how a store is a better paradigm to share data while keeping components encapsulated. I will give it a go next week! |
I think the README should have a warning that this projet is not compatible with v3. Thanks! |
@pascalandy sounds like a good idea, do you mind sending a PR? Thanks |
@SimoTod done :) |
Thanks @pascalandy |
Hi Support AlpineJS V3 alpine-collective ..?
The text was updated successfully, but these errors were encountered: