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

Remove unused hook #2671

Merged
merged 1 commit into from
Sep 14, 2023
Merged

Remove unused hook #2671

merged 1 commit into from
Sep 14, 2023

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Sep 14, 2023

Removing some dead code. useRisingEdge was a hook to run an effect when a value changes from false to true.

@Janpot Janpot added the core Infrastructure work going on behind the scenes label Sep 14, 2023
Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

😂💪🏻

@Janpot Janpot marked this pull request as ready for review September 14, 2023 08:30
@Janpot Janpot merged commit f39909b into mui:master Sep 14, 2023
9 of 10 checks passed
@Janpot Janpot deleted the remove-unused-hook branch September 14, 2023 08:30
@@ -1,17 +0,0 @@
import * as React from 'react';
import useEvent from './useEvent';
Copy link
Member

@oliviertassinari oliviertassinari Sep 15, 2023

Choose a reason for hiding this comment

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

useEvent looks almost identical to @mui/utils/useEventCallback.

Copy link
Member Author

@Janpot Janpot Sep 16, 2023

Choose a reason for hiding this comment

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

it's a direct implemention of https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
the idea was to one day replace it with the built-in, but the RFC got abandoned

Copy link
Member

@oliviertassinari oliviertassinari Sep 16, 2023

Choose a reason for hiding this comment

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

Is there an opportunity to merge these two helpers? But I'm not sure https://github.com/mui/mui-toolpad/blob/0c05f1a5d655f711b704f04b3f9998a9422f776c/packages/toolpad-app/src/utils/useEvent.ts looks a bit more bundle size and none React 17 compatible. I didn't know about the useInsertionEffect hook, interesting.

I linked the RFC in mui/material-ui@89635d1.

Copy link
Member Author

@Janpot Janpot Sep 17, 2023

Choose a reason for hiding this comment

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

Is there an opportunity to merge these two helpers?

We could use useEventCallback in Toolpad. I'm just curious, what is an enhanced effect? And is there an opportunity to better name/document this hook?

I didn't know about the useInsertionEffect hook, interesting.

The RFC polyfill mentions an effect with comment:

// In a real implementation, this would run before layout effects
useLayoutEffect(() => {

Which is what useInsertionEffect does. In practice we can probably rely on useLayoutEffect.

Copy link
Member

Choose a reason for hiding this comment

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

I'm just curious, what is an enhanced effect? And is there an opportunity to better name/document this hook?

A use layout effect but without the server side hydration warning. Yeah, the name is subjective 😁. The name used also impacts the eslint rule, e.g. facebook/react#25285. We would need to update https://github.com/mui/material-ui/blob/89635d1dd83b9533e5853a287df014f10f07f90f/.eslintrc.js#L123 too.

Copy link
Member Author

@Janpot Janpot Sep 18, 2023

Choose a reason for hiding this comment

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

Quick google shows mostly useIsomorphicLayoutEffect being used as a name. I'm just mostly interested in adding a comment there. Just a few extra points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants