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

New setting to avoid the passToClient error #1776

Open
brillout opened this issue Jul 30, 2024 · 6 comments
Open

New setting to avoid the passToClient error #1776

brillout opened this issue Jul 30, 2024 · 6 comments
Labels
enhancement ✨ New feature or request

Comments

@brillout
Copy link
Member

brillout commented Jul 30, 2024

Description

// pages/+config.js

export default {
  // Don't throw an error upon accessing missing pageContext.someProp
  // Also don't show a warning.
  passToClientErrorIgnore: ['someProp']
}

The idea is tell users to let us know when and why they have to use passToClientErrorIgnore, so that Vike can update its internal ignore list.

Ideally, users should never have to use passToClientErrorIgnore.

See also:

Alternative name: pageContextClientAccessErrorIgnore.

@brillout brillout added the enhancement ✨ New feature or request label Jul 30, 2024
@brillout brillout changed the title New setting to make the passToClient error a warning instead of an error New setting to avoid the passToClient error Aug 1, 2024
@pdanpdan
Copy link

pdanpdan commented Aug 1, 2024

I would use something like passToClientErrorIgnore - passToClientIgnore might make one think here you configure what keys will not be passed to the client.

@brillout
Copy link
Member Author

brillout commented Aug 1, 2024

👍 Good idea, ticket updated.

@pdanpdan
Copy link

pdanpdan commented Aug 1, 2024

Now that I think more about it, maybe a name that references pageContext would be better.
The error if in the form of [vike][Wrong Usage] pageContext.xxx isn't defined on the client-side.
Maybe pageContextClientAccessErrorIgnore :)

@brillout
Copy link
Member Author

brillout commented Aug 1, 2024

I thought about this as well; the reason I went for something prefixed with passToClient* is because the error mentions passToClient and also points to https://vike.dev/passToClient#error.

Yes, it isn't accurate technically speaking, but I'm thinking it's more guessable. I feel like pageContextClientAccessErrorIgnore is maybe a bit hard to guess 🤔

@brillout
Copy link
Member Author

brillout commented Aug 1, 2024

I feel like pageContextClientAccessErrorIgnore is maybe a bit hard to guess 🤔

Hm, actually, it's quite guessable. So, yea, maybe we should go for that.

@pdanpdan
Copy link

pdanpdan commented Aug 1, 2024

Yes, not a very nice name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants