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

build(esm, cjs modules): add 'use-client' directive for esm and cjs m… #207

Merged
merged 4 commits into from
Dec 28, 2023

Conversation

jmestxr
Copy link
Contributor

@jmestxr jmestxr commented Dec 18, 2023

Ticket SGDS-668

React components are client side components as it uses hook (useContext and in future useId). 

Users of nextjs will have to add "use client" whenever they use our components and it becomes a hassle as they have create a file and wrap our components with 'use client'.  This is ok for big components that they need to customize and wrap over, but for smaller components like button which they expect to use out of the hood , its quite a hassle. 

Client side react users are unaffected, and should be unaffected by this update. 

Solution found at https://www.misha.wtf/blog/rollup-server-components

Tested on cypress e2e apps to be working.

…odules

Users of nextjs have to add "use client" whenever they use sgds components
and it becomes a hassle as they have create a file and wrap our components with 'use client'.

To add 'use-client' directive during build.

Client side react users are unaffected, and should be unaffected by this update.
@clukhei clukhei self-requested a review December 22, 2023 01:52
remove use client from nextjs tester app

remove usage of subcomponents from nextjs app

update exports of subcomponents in src folder
Copy link
Collaborator

@clukhei clukhei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed "use client" from nextjs page.tsx file to test the new "use client" directive defined at the top of the components file.

added exports of individual subcomponents due to upstream issue of nextjs vercel/next.js#51593

@clukhei clukhei merged commit f73610c into v2 Dec 28, 2023
@clukhei clukhei deleted the add-use-client branch December 28, 2023 02:39
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

Successfully merging this pull request may close these issues.

2 participants