Skip to content
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

Vue warn about getters not being side-effect free #2985

Open
DamianGlowala opened this issue Feb 15, 2024 · 5 comments
Open

Vue warn about getters not being side-effect free #2985

DamianGlowala opened this issue Feb 15, 2024 · 5 comments
Assignees

Comments

@DamianGlowala
Copy link

What package within Headless UI are you using?

@headlessui/vue

What version of that package are you using?

insiders

What browser are you using?

Chrome

Reproduction URL

image
image

https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free

Describe your issue

Seeing Vue warnings about getters not being side-effect free for what to me seems like a Headless UI component.

@thecrypticace thecrypticace self-assigned this Feb 15, 2024
@wahyubaskara
Copy link

Same issue

@faridibin
Copy link

Same Issue, started happening after last update

@SummerPaX
Copy link

SummerPaX commented Feb 19, 2024

I have also the same issue with headlessui tabs, and I did some digging.

Its possible that this computed might be one of the culprits, because it modifies the SSRContext.

// packages/@headlessui-vue/src/components/tabs/tabs.ts

let mySSRIndex = computed(() => {
  if (SSRContext.value) {
    let mySSRIndex = SSRContext.value.panels.indexOf(props.id)
    if (mySSRIndex === -1) return SSRContext.value.panels.push(props.id) - 1
    return mySSRIndex
  }

  return -1
})

I don't think its that big of an issue because every computed is only executed twice and has no heavy code, but the warning messages are clogging up my console window.Thanks for doing such great work

@m-shum
Copy link

m-shum commented Feb 23, 2024

Yup exactly the same issue here – happening for me specifically with the Tabs component of nuxtUI. The console noise is a headache for sure.

@MickL
Copy link

MickL commented Feb 25, 2024

I think it helps more to just upvote the issue instead of writing "same issue" :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants