question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: export `UseContextReturn`

See original GitHub issue

🆒 Your use case Add a description of your use case, and how this feature would help you.

I was trying to get the cookie-universal-nuxt module work in my project. I need to get $cookies from the context returned by useContext. However it $cookies doesn’t exist in UseContextReturn and there’s no way for me to extend it since it’s not exported.

🆕 The solution you’d like Can you please export this type?

🔍 Alternatives you’ve considered By the way, I ended up using this workaround, which seems to be a bit ugly:

const {
  $axios,
  $cookies,
}: {
  $axios: NuxtAxiosInstance
  $cookies: NuxtCookies
} = useContext() as any

ℹ️ Additional info No

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Feb 5, 2021

@dzcpy Looking at the type declaration, you will need to access it from app - so:

const { app: { $cookies } } = useContext()

In other cases though, you shouldn’t augment UseContextReturn - just augment Nuxt types in the normal way and it will pick it up - see docs.

0reactions
dzcpycommented, Feb 5, 2021

@dzcpy Looking at the type declaration, you will need to access it from app - so:

const { app: { $cookies } } = useContext()

In other cases though, you shouldn’t augment UseContextReturn - just augment Nuxt types in the normal way and it will pick it up - see docs.

Thanks, it worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

docs: How do I extend UseContextReturn to account for other ...
I'm currently using @nuxtjs/auth-next among other plugins that all inject into the context. However, when accessing these properties with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found