-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Pagination] v5 usePagination requires @emotion #27282
Comments
Thanks for the report @MichielDeMey Ideally we should move all hooks to the @michaldudak should we do this? Depending on the |
@mnajdova While I agree with all you said, I would like to raise a quick-win opportunity. AFAIK the main issue of @MichielDeMey is that tree shaking is disabled in dev mode, usePagination imports core/utils, that imports SvgIcon, that imports system, that import styled, that imports emotion => his codesandbox break. So we force him to install emotion, and he might think that emotion will be bundled in production (it won't, tree shaking kicks in prod mode). Now, we could force the treeshaking in dev mode and call it a day 😁: diff --git a/packages/material-ui/src/usePagination/usePagination.js b/packages/material-ui/src/usePagination/usePagination.js
index 4f15278cb1..561747a5e4 100644
--- a/packages/material-ui/src/usePagination/usePagination.js
+++ b/packages/material-ui/src/usePagination/usePagination.js
@@ -1,4 +1,4 @@
-import { useControlled } from '../utils';
+import { unstable_useControlled as useControlled } from '@material-ui/utils';
export default function usePagination(props = {}) {
// keep default values in sync with @default tags in Pagination.propTypes emotion is an optional peer dependency, nothing to install, no warnings. Then fix the problem at the root (not the surface) with the unstyled package (to remove any fear that the developers might have, for social proof, etc.) in mui/base-ui#10. |
@oliviertassinari I did verify that emotion is not bundled in the final release bundle due to tree shaking. 😉 |
The same issue with |
Sure, seems like a pretty low hanging fruit. There is a few more components that could simply be moved to unstyled. I'll focus on these before taking on the next "big" one. |
When simply using the
usePagination
hook provided by MaterialUI,@emotion/styled
and@emotion/react
are mandatory dependencies, otherwise it will throw a Webpack build error:Current Behavior 😯
Does not compile unless
@emotion
packages are installedExpected Behavior 🤔
I would expect to be able to compile without an exception since no styles are actually used or needed when using the hook.
Steps to Reproduce 🕹
Codesandbox to reproduce the isse
https://codesandbox.io/s/fluentui-use-paginate-7czwv?file=/src/components/Paginate/index.tsx
Steps:
@emotion
packagesContext 🔦
We're trying to use the new headless components (hooks) provided by MaterialUI, but without any styling requirements.
Your Environment 🌎
`npx @material-ui/envinfo`
The text was updated successfully, but these errors were encountered: