-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: add "use client" to components that use client side only React APIs (support for RSC) #2874
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
392be21
to
2fd02fd
Compare
…APIs (support for RSC) We have received several request to add a ["use client"](https://react.dev/reference/react/use-client) directive on top of each React component file that uses client side only React APIs. The reason is because Next.js takes in use a beta version of React to make RSC work (which is not OK in my opinion – its a super aggressive move 😣). To make a first move on this, I think we should automate this. And one way to do so, is to use Babel.js – because we use it in our tool-chain. There is already a very well written and tested plugin, written by Kyle Tsang I suggest to try out. 👉 [babel-plugin-transform-next-use-client](https://github.com/kyletsang/babel-plugin-transform-next-use-client) This must be the first time we take in use a dependency with 0 GitHub stars. If it turns out to work as expected, we should all give it a start of course.
2fd02fd
to
b49a404
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, let's give it a go 👍
Better than adding these lines of code in all our components, etc.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b49a404:
|
## [10.13.0](v10.12.0...v10.13.0) (2023-11-12) ### 🐛 Bug Fixes * **Autocomplete:** ensure correct value selection during data change ([#2863](#2863)) ([d229ec2](d229ec2)) * **Autocomplete:** ensure on_change is firered during dataset update ([266ab6a](266ab6a)) * **PhoneNumber:** ensure correct selection of value ([#2852](#2852)) ([a20a764](a20a764)) * remove nullish operator to support Storybook v6 ([#2873](#2873)) ([f0bab63](f0bab63)) * typescript react type resolution in monorepos ([#2866](#2866)) ([44f04f3](44f04f3)) ### ✨ Features * **Accordion:** change sbanken expand icon to chevron ([#2854](#2854)) ([a7cb8b9](a7cb8b9)) * add "use client" to components that use client side only React APIs (support for RSC) ([#2874](#2874)) ([a84e962](a84e962)) * **Button:** change sbanken primary button text color to white ([#2855](#2855)) ([1571138](1571138)) * **Typography:** change sbanken bold to medium ([#2808](#2808)) ([4b0f930](4b0f930)) ### 📝 Documentation * **About:** add Snorre/Henrik/Ynge as contributors ([#2885](#2885)) ([fff72da](fff72da)) * **Autocomplete:** adds default value to keep_value props ([#2867](#2867)) ([7cae1fd](7cae1fd)) * fix font docs ([#2849](#2849)) ([13beec9](13beec9)) * **Ingress:** adds Ingress to docs ([#2879](#2879)) ([f771f3d](f771f3d)) * **Lead:** adds Lead to docs ([#2877](#2877)) ([0c0da7f](0c0da7f))
🎉 This PR is included in version 10.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
We have received several request to add a "use client" directive on top of each React component file that uses client side only React APIs.
The reason is because Next.js takes in use a beta version of React to make RSC work (which is not OK in my opinion – its a super aggressive move 😣).
To make a first move on this from our side, I think we should automate this. And one way to do so, is to use Babel.js – because we use it in our tool-chain.
There is already a very well written and tested plugin, written by Kyle Tsang I suggest to try out.
👉 babel-plugin-transform-next-use-client
This must be the first time we take in use a dependency with 0 GitHub stars. If it turns out to work as expected, we should all give it a star of course!
Other notes: