当props.pop
更改时,我试图使过渡缓慢(500ms)缩放Brandsdiv。 pop
等于true
或false
。当前,transform: ${props => (props.pop ? "scale(1.2)" : "scale(1)")};
可以正常工作,并且在pop = true
时缩放div,但是过渡不起作用-缩放比例突然改变。
import React from 'react'
import styled from 'styled-components'
const LogoImg = styled.img`
max-width: 100%;
padding: 5px;
`
export default function FeaturedManufacturerLink(props) {
const {
brandPagePath,
logo,
pop
} = props
const Brandsdiv = styled.div`
transition: transform 500ms;
display: flex;
width: 116px;
height: 85px;
border-radius: 50%;
margin: 25px 35px;
align-items: center;
text-align: center;
transform: ${props => (props.pop ? "scale(1.2)" : "scale(1)")};
`
return (
<Brandsdiv pop={pop}>
<a href={brandPagePath}>
<LogoImg src={logo} />
</a>
</Brandsdiv>
)
}
答案 0 :(得分:0)
我搬了const Brandsdiv
。道具更改pop
导致组件重新呈现。