Material UI: bug with react transition group v 2.2.0

吃可爱长大的小学妹 提交于 2019-12-24 07:20:54

问题


I'm using <Transition> as explained in main documentation of React Transition Group.

import React from 'react';
import PropTypes from 'prop-types';
import Transition from 'react-transition-group/Transition';

const defaultStyle = {
 transition: `opacity 300ms ease-in-out`,
 opacity: 0,
};

const transitionStyles = {
 entering: { opacity: 1 },
 entered: { opacity: 1 },
};

const Fade = ({
 in: inProp,
 children,
}) => (
 <Transition in={inProp} timeout={300}>
  {state => (
   <div
    style={{
      ...defaultStyle,
      ...transitionStyles[state],
    }}
  >
    {children}
  </div>
)}
</Transition>
);

Fade.propTypes = {
 in: PropTypes.bool.isRequired,
 children: PropTypes.node.isRequired,
};

export default Fade;

It works, but not so well with Material UI, especially with Buttons, everywhere on my app: when I click on them, appears a white div behind them:

<div in="false" style="position: absolute; top: -88.218px; left: -97.218px; height: 220.436px; width: 220.436px; border-radius: 50%; background-color: rgb(255, 255, 255);"></div>

and this weird error in console:

Warning: Unknown props `onExited`, `appear`, `enter`, `exit` on <div> tag. Remove these props from the element.

Those props are about Transition, but I can't understand the problem.

I'm using React 15.6.1, Material ui 0.18.7 and React Transition Group 2.2.0


回答1:


I encountered this bug today, and I logged an issue + repro case on their github.

https://github.com/callemall/material-ui/issues/8046

(repro: https://codesandbox.io/s/q9o5q0l5nw)

I have tested in v1.0.0-beta.8 and it looks like it's working fine (https://codesandbox.io/s/r5nplz89nn).

The project's stance is essentially "material-ui v0.x is legacy code". So your options are either; disable ripples across your app, fix it for them via a PR, or move to the unfinished v1 beta branch.



来源:https://stackoverflow.com/questions/45592444/material-ui-bug-with-react-transition-group-v-2-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!