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

[charts][core] Replace useIsomorphicLayoutEffect of @react-spring/web for Base UI's helper #13431

Open
oliviertassinari opened this issue Jun 9, 2024 · 5 comments
Labels
component: charts This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 9, 2024

Steps to reproduce

import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';

looks suboptimal to me. useIsomorphicLayoutEffect should be using Base UI helper instead.

@oliviertassinari oliviertassinari added core Infrastructure work going on behind the scenes status: waiting for maintainer These issues haven't been looked at yet by a maintainer component: charts This is the name of the generic UI component, not the React module! labels Jun 9, 2024
@LukasTy
Copy link
Member

LukasTy commented Jun 10, 2024

@oliviertassinari could you confirm the @mui/base helper you are referring to? 🤔
Maybe it is import useEnhancedEffect from '@mui/utils/useEnhancedEffect'; you were referring to? 🤔
In this case, it seems that the former might have a bit less coverage... 🙈

const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;

vs

var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
var useIsomorphicLayoutEffect = isSSR() ? useEffect : useLayoutEffect;

@michelengelen
Copy link
Member

is this still a valid issue then? 🤔

@LukasTy
Copy link
Member

LukasTy commented Jun 14, 2024

Probably a question to @mui/xcharts. 🤔
IMHO, using the existing effect doesn't hurt, especially if and when charts would drop material-ui dependency (then having a slight discrepancy between behaviors wouldn't have any effect).
On the other hand, WDYT @michaldudak, would it make sense to extend the useEnhancedEffect with the additional checks that @react-spring/web is doing? 🤔

@alexfauquette alexfauquette removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 14, 2024
@michaldudak
Copy link
Member

I haven't seen any issues regarding the current implementation, but indeed it seems that Deno has window defined during SSR. I'm OK with making it more reliable (I'd also call it useIsomorphicLayoutEffect, because useEnhancedEffect tells users exactly nothing, but that's another story ;).

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Jun 15, 2024

could you confirm the @mui/base helper you are referring to?

@LukasTy I was thinking of useEnhancedEffect indeed. This helper still needs to be exposed from @base_ui/react/useEnhancedEffect but this issue will help us track progress / coordinate.

it seems that the former might have a bit less coverage

It feels like useEnhancedEffect is better because it's less bundle size, and I'm not aware of people complaining about its behavior.

using the existing effect doesn't hurt, especially if and when charts would drop material-ui dependency

It's part of why I opened this issue, the value I see:

  • As MUI X move to have a great unstyled (and maybe even headless) story, will move some of its dependencies to Base UI. In practice, it will likely just be about removing all reexports from Material UI to have a clear separation for what is from which library.
  • This duplication is extra bundle size.
  • This behavior difference. If one is better than the other, the other should follow suite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes
Projects
None yet
Development

No branches or pull requests

5 participants