ReactJS: Fade in div and fade out div based on state

后端 未结 3 1109
心在旅途
心在旅途 2020-12-29 14:43

So, I am trying to fade in and fade out a set of inputs based on what button the user clicks. I tried using jQuery, but, the div was fading in and fading out at the same spe

3条回答
  •  灰色年华
    2020-12-29 15:01

    A simple way to achieve this with styled components...

    const Popup = styled.div`
      width: 200px;
      height: 200px;
      transition: opacity 0.5s;
      opacity: ${({ showPopup }) => (showPopup ? '1' : '0')};
    `;
    

    
      {...}
    
    

提交回复
热议问题