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

[TouchRipple] Remove findDOMNode usage #14825

Merged
merged 1 commit into from
Mar 11, 2019

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Mar 10, 2019

Use ref on the DOM element type instead of findDOMNode(this).

@eps1lon eps1lon added the new feature New feature or request label Mar 10, 2019
@eps1lon eps1lon added this to the v4 milestone Mar 10, 2019
@mui-pr-bot
Copy link

mui-pr-bot commented Mar 10, 2019

Details of bundle changes.

Comparing: a5b8011...b11f755

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core +0.02% 🔺 +0.02% 🔺 362,777 362,841 92,213 92,235
@material-ui/core/Paper 0.00% 0.00% 68,878 68,878 20,170 20,171
@material-ui/core/Paper.esm 0.00% -0.04% 63,340 63,340 19,272 19,264
@material-ui/core/Popper 0.00% +0.01% 🔺 30,460 30,460 10,573 10,574
@material-ui/core/styles/createMuiTheme 0.00% 0.00% 17,284 17,284 5,700 5,700
@material-ui/core/useMediaQuery 0.00% 0.00% 2,471 2,471 1,035 1,035
@material-ui/lab +0.04% 🔺 +0.05% 🔺 170,747 170,811 50,065 50,090
@material-ui/styles 0.00% -0.32% 57,220 57,220 16,273 16,221
@material-ui/system 0.00% 0.00% 17,041 17,041 4,493 4,493
Button +0.07% 🔺 +0.05% 🔺 91,152 91,216 26,939 26,952
Modal 0.00% -0.01% 90,261 90,261 26,724 26,721
colorManipulator 0.00% 0.00% 3,232 3,232 1,298 1,298
docs.landing 0.00% 0.00% 51,908 51,908 11,302 11,302
docs.main 0.00% -0.00% 647,808 647,828 201,557 201,551
packages/material-ui/build/umd/material-ui.production.min.js +0.02% 🔺 +0.02% 🔺 311,179 311,243 85,197 85,210

Generated by 🚫 dangerJS against b11f755

>
{this.state.ripples}
</TransitionGroup>
<span className={clsx(classes.root, className)} ref={this.container} {...other}>
Copy link
Member Author

Choose a reason for hiding this comment

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

Spreading to the span follows the API docs:

Any other properties supplied will be spread to the root element (native element).
-- https://material-ui.com/api/touch-ripple/#props

It's only accessible via TouchRippleProps in ButtonBase. The PR that introduced this prop mentioned "changing color of the ripple" as a use case. Sounds like the native element is only needed for that not the TransitionGroup

Copy link
Member

Choose a reason for hiding this comment

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

Great change 👍

{this.state.ripples}
</TransitionGroup>
<span className={clsx(classes.root, className)} ref={this.container} {...other}>
<TransitionGroup component={null} enter exit>
Copy link
Member Author

Choose a reason for hiding this comment

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

https://reactcommunity.org/react-transition-group/transition-group#TransitionGroup-prop-component

If TransitionGroup would forward refs or offer some innerRef we could avoid that nesting. I feel way more comfortable not exposing the TransitionGroup though. Making this part of our public API created a tight coupling that forces us to continue using it even though react-transition-group is not strict mode compliant.

assert.strictEqual(wrapper.name(), 'TransitionGroup');
assert.strictEqual(wrapper.props().component, 'span');
assert.strictEqual(wrapper.hasClass(classes.root), true);
it('should render a span', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

TransitionGroup is not part of the public API

@eps1lon eps1lon force-pushed the feat/TouchRipple/no-findDOMNode branch from ed930a6 to b11f755 Compare March 10, 2019 17:03
import { StandardProps } from '..';

export type TouchRippleProps = StandardProps<
TransitionGroup.TransitionGroupProps,
React.HTMLAttributes<HTMLElement>,
Copy link
Member Author

Choose a reason for hiding this comment

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

Documentation > Code i.e. type definitions were wrong.

@eps1lon eps1lon marked this pull request as ready for review March 10, 2019 18:40
@oliviertassinari oliviertassinari merged commit fe5b011 into mui:next Mar 11, 2019
@eps1lon eps1lon deleted the feat/TouchRipple/no-findDOMNode branch March 11, 2019 10:55
@eps1lon eps1lon restored the feat/TouchRipple/no-findDOMNode branch March 11, 2019 10:55
@eps1lon eps1lon deleted the feat/TouchRipple/no-findDOMNode branch March 11, 2019 10:56
@eps1lon eps1lon restored the feat/TouchRipple/no-findDOMNode branch March 11, 2019 10:56
@eps1lon eps1lon deleted the feat/TouchRipple/no-findDOMNode branch March 11, 2019 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants