Open kentcdodds opened 7 months ago
I know this seems pretty old, but what is the thinking behind import client-only
being a better approach compared too use client
from a library perspective. Is the expectation that everyone just creates a wrapper around the component and add use-client
?
The thinking is that the error message is more useful if someone accidentally imports it in the wrong environment.
I see. I guess my initial impression was that as someone using the library, it was less convenient than just having 'use client' embedded in the component itself.
It could be ignorance on my part, but I'm guessing that even with 'use client' in the component, you could still run into issues?
Describe the feature / bug 📝:
Right now sonner publishes "use client" in it's source. This should be an application-level concern rather than a library one. For more on this: https://github.com/adobe/react-spectrum/pull/5826
As another motivation, using sonner with vite currently gives this error:
I think following the pattern taken by react-aria (simply using the
client-only
module by Sebastian) is the right approach here:The resulting error message is better and it's less limiting.