Comment

Comment by wakeless

This is actually a really weird example of using the Context API. I have no idea why you would want to use it to manage a single switch of state.

The far better examples are providing a "theme" across multiple disparate components, and each of them being able to access the colours, or styles. (You could also just use CSS)

The other good example is being able to set the logged in user into a context and then being able to consume the context if you need access to the logged in user.

parent wakeless 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton