Skip to content

Commit

Permalink
fix(material): move the ref check
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrgm committed Sep 2, 2022
1 parent 20d2d70 commit b26b7e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-balloons-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@suid/material": patch
---

Fix console error in `ButtonBase`
27 changes: 13 additions & 14 deletions packages/material/src/ButtonBase/ButtonBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,19 +337,6 @@ const ButtonBase = $.component(function ButtonBase({
const enableTouchRipple = () =>
mountedState() && !props.disableRipple && !props.disabled;

if (process.env.NODE_ENV !== "production") {
createEffect(() => {
if (enableTouchRipple() && !ripple.ref) {
console.error(
[
"MUI: The `component` prop provided to ButtonBase is invalid.",
"Please make sure the children prop is rendered in this custom component.",
].join("\n")
);
}
});
}

return (
<ButtonBaseRoot
{...buttonProps()}
Expand Down Expand Up @@ -377,7 +364,19 @@ const ButtonBase = $.component(function ButtonBase({
{props.children}
<Show when={enableTouchRipple()}>
<TouchRipple
ref={ripple}
ref={(ref) => {
ripple(ref);
if (process.env.NODE_ENV !== "production") {
if (!ref) {
console.error(
[
"MUI: The `component` prop provided to ButtonBase is invalid.",
"Please make sure the children prop is rendered in this custom component.",
].join("\n")
);
}
}
}}
center={props.centerRipple}
{...(props.TouchRippleProps || {})}
/>
Expand Down

0 comments on commit b26b7e4

Please sign in to comment.