reactjs - 反应过渡组删除/插入简单功能反应组件的动画
问题描述
我希望在 preact 中创建一个用于动画目的的反应过渡组(但这个问题也适用于反应。)我有一个我写的 Square 功能组件和一个渲染四个 Square 的页面和一系列按钮将删除/插入/删除+插入。我看过一些关于反应过渡组的博客文章,并试图应用它们,但遇到了一些障碍。
这是我的基本 Square 组件
function Square (props) {
const { color, x, y, width, height, style, status, ...passThrough } = props;
return (
<g style={style}>
<rect
fill={color}
x={x}
y={y}
width={width}
height={height}></rect>
</g>
)
}
这是基本动画发生的地方
<Transition in={transitionProp} timeout={500}>
{state => (
<div> {state} </div>
)}
<svg width="600" height="600">
{renderSquareData(squareData2, style[state])}
</svg>
</Transition>
然而,该状态当前没有显示任何内容,在 div 中没有呈现任何内容。我想知道在这种情况下如何将 TransitionGroup 用于功能组件。我想根据过渡状态理想地应用 defaultStyle、transitionStyle。
const style = {
entering: {
transition: `opacity 300ms ease-in-out`,
opacity: 1
},
entered: {
transition: `opacity 300ms ease-out`,
opacity: 0
}}
解决方案
推荐阅读
- amazon-web-services - 无法使用 SDK 向 AWS SQS 发送消息
- javascript - 为什么以下正则表达式会删除单引号内的边界字符?
- firebase - 用户登录 SaaS 应用程序时创建 firebase 项目
- c# - 多个 Redis Nuget 包,其中一个用于 NETCORE 3.1
- sql-server - 更改 VS 中 SQL Server Reporting Services 报表向导使用的字体的默认数据
- python - 展平列表时不需要的副作用
- javascript - 在 Node.js 和 Knex 中向现有表添加列
- javascript - 如何在 Rails 6 中使用 Webpacker 加载 d3.js?
- python - python将json数据加载到数据映射类对象
- javascript - react native ios app中无法识别的自定义字体