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

[Transition] Prevent passing undefined argument to callbacks #21158

Merged
merged 2 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/material-ui/src/Collapse/Collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ const Collapse = React.forwardRef(function Collapse(props, ref) {
const [node, isAppearing] = enableStrictModeCompat
? [nodeRef.current, nodeOrAppearing]
: [nodeOrAppearing, maybeAppearing];
callback(node, isAppearing);

// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
if (isAppearing === undefined) {
callback(node);
} else {
callback(node, isAppearing);
}
}
};

Expand Down
8 changes: 7 additions & 1 deletion packages/material-ui/src/Fade/Fade.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ const Fade = React.forwardRef(function Fade(props, ref) {
const [node, isAppearing] = enableStrictModeCompat
? [nodeRef.current, nodeOrAppearing]
: [nodeOrAppearing, maybeAppearing];
callback(node, isAppearing);

// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
if (isAppearing === undefined) {
callback(node);
} else {
callback(node, isAppearing);
}
}
};

Expand Down
5 changes: 3 additions & 2 deletions packages/material-ui/src/Grow/Grow.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ const Grow = React.forwardRef(function Grow(props, ref) {
const [node, isAppearing] = enableStrictModeCompat
? [nodeRef.current, nodeOrAppearing]
: [nodeOrAppearing, maybeAppearing];
const isExitCallback = isAppearing === undefined;
if (isExitCallback) {

// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
if (isAppearing === undefined) {
callback(node);
} else {
callback(node, isAppearing);
Expand Down
7 changes: 6 additions & 1 deletion packages/material-ui/src/Slide/Slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ const Slide = React.forwardRef(function Slide(props, ref) {

const normalizedTransitionCallback = (callback) => (isAppearing) => {
if (callback) {
callback(childrenRef.current, isAppearing);
// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
if (isAppearing === undefined) {
callback(childrenRef.current);
} else {
callback(childrenRef.current, isAppearing);
}
}
};

Expand Down
8 changes: 7 additions & 1 deletion packages/material-ui/src/Zoom/Zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ const Zoom = React.forwardRef(function Zoom(props, ref) {
const [node, isAppearing] = enableStrictModeCompat
? [nodeRef.current, nodeOrAppearing]
: [nodeOrAppearing, maybeAppearing];
callback(node, isAppearing);

// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
if (isAppearing === undefined) {
callback(node);
} else {
callback(node, isAppearing);
}
}
};

Expand Down