【问题标题】:Trying to use React Spring with Semantic UI React, simple example尝试将 React Spring 与 Semantic UI React 一起使用,简单示例
【发布时间】:2020-03-29 17:26:34
【问题描述】:

大家好,感谢您的宝贵时间。

我正在尝试将 Semantic-ui-React 与 React Spring 一起使用,这里我有一个简短的示例...


import React from 'react'
import {Segment, Header} from "semantic-ui-react"
import {useSpring, animated, config} from "react-spring"
function Semantix() {

    const fading = useSpring({ config: config.slow,

        from : {
            opacity : 0,
            marginLeft:"-50px"
        },
        to : {
            opacity : 1,
            marginLeft: "300px"
        }
    })



    return (
        <Segment>
            <animated.Header style={fading}>Hey Hey</animated.Header>
        </Segment>
    )
}

export default Semantix



对于这个愚蠢的问题,我深表歉意,但我当时有点绝望,任何帮助将不胜感激

【问题讨论】:

    标签: reactjs semantic-ui-react react-spring


    【解决方案1】:

    在动画中,只有原生元素作为常量存在,例如animated.div。您必须使用动画作为其他非原生元素的函数,例如来自语义 UI 的组件:animated(Header)

      const AnimatedHeader = animated(Header);
    
      return (
        <Segment>
          <AnimatedHeader style={fading}>Hey Hey</AnimatedHeader>
        </Segment>
      );
    

    【讨论】:

    • 我在保存代码框时遇到了一些问题,所以我删除了这个例子。无论如何,它没有显示正确的代码。
    • 哦,谢谢 PS:codeandbox 链接不起作用
    猜你喜欢
    • 2019-02-13
    • 2021-10-18
    • 1970-01-01
    • 2017-10-10
    • 2018-11-10
    • 2017-12-09
    • 2017-10-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多