-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
feat: add brisa adapter #1913
feat: add brisa adapter #1913
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@osdiab @aralroca I've tried to come up with a v0 for brisa. Adapter is in Also, I'd love to know if there's any more JSX differences to watch out for. E.g. passing data-attr=undefined to react element removes the data-attr, but brisa leaves it with "undefined" string value |
That's cool! 🔥 |
About the behavior of JSX, it is very much inspired by React, so the difference has to be minimal. As a difference, instead of |
@aralroca @osdiab There's a behaviour that seems problematic for the adapter, I'm keeping zag state like this: const state = state(service.state) service is zag's running state. When service is mutated, it seems brisa const unsubscribe = subscribe(service.state, () => {
state.value = snapshot(service.state)
}) |
Closing this for now. Will be picked up after problems are clarified |
I had not seen the question until now. In Brisa "state" also serves as "ref", and the code you mention should work, although I would not put the variable name the same. This should work: export default function Component({}, { state, onMount, cleanup }) {
const zagState = state(service.state)
onMount(() => {
const unsubscribe = subscribe(service.state, () => {
zagState.value = snapshot(service.state)
})
cleanup(() => unsubscribe())
})
return <div>{JSON.parse(zagState.value)}</div>
} |
@aralroca Still wasn't able to get it to work. Would be awesome if you could help look into it. It's the |
I think the problem is that in Brisa we have this condition inside the signal setter: This way if the value is the same we avoid updating the DOM with the same value. I think the problem comes from here if it is mutating without being reactive inside the Zag service. I don't know how feasible is to do something like this to force reactivity: const unsubscribe = subscribe(service.state, () => {
// Create a new object to force reactivity even if the values are the same
state.value = { ...snapshot(service.state) };
}); we were not contemplating that mutations could be made external to the state in this way. If this is a common behavior of several libraries, we can reconsider changing this part. |
add brisa adapter
related #1912 brisa-build/brisa#529