`react-transition-group` callbacks called with undefined argument
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Some callbacks (e.g. onExited
) are called with undefined argument.
props.onExited(node, undefined)
Expected Behavior 🤔
Callbacks to be called with the right arguments accordingly
props.onExited(node)
props.onEntered(node, isAppearing)
Steps to Reproduce 🕹
https://codesandbox.io/s/material-demo-ghrv2
Steps:
- Toggle the “show” switch twice
- check the console. Callback is called with
node
andundefined
arguments.
Context 🔦
It may not be as important if people are using the callbacks as is, but in notistack I need to call the callbacks with an additional argument (snackbar’s unique id). And having an undefined agument creates a gap.
This caused a bug in latest release of notistack. Where I was expecting to receive snackbar’s unique key as the second argument, but I was receiving it as the third argument. The fix was released as a temporary solution.
Issue is introduced in https://github.com/mui-org/material-ui/pull/20952/. More specifically, any instances in the following form should be fixed: example. Alternatively normalizedTransitionCallback
can be modified.
- const handleExited = normalizedTransitionCallback(onExited);
+ const handleExited = normalizedTransitionCallback((node) => {
onExited(node)
});
The reason being normalizedTransitionCallback always calls the callback with 2 arguments. This is the case for some callbacks which have isApearing
as the second argument. But don’t apply to others (e.g. onExited
) where it’s called with one argument (that being node
).
Happy to create a PR once the bug is confirmed.
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v4.9.14 |
React | v16.12.0 |
Browser | Chrome |
TypeScript | v3.8.3 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Sounds fair 👍🏼I’ll open a PR in the upcoming days
If you want to spend time on the issue then go ahead. It’s open source after all. But we won’t spend time on it since it looks like this is a dev only warning about a possible extraneous parameter that can be fixed in userland.