【问题标题】:react-spring and typescript not callable errorreact-spring 和 typescript 不可调用错误
【发布时间】:2021-04-01 03:31:09
【问题描述】:

我无法制作最简单的 react-spring 示例:

import { useSpring } from 'react-spring/three'

export const myComponent = () => {
    const [spring, setSpring] = useSpring(() => ({ xpos: 0 }))
    setSpring({xpos: 10})

    return (
        <Canvas />
    )
}

它给了我这个:

未捕获的类型错误:setSpring 不是函数

【问题讨论】:

    标签: react-spring


    【解决方案1】:

    这里有更多讨论:https://github.com/pmndrs/react-spring/issues/1359

    当前的解决方法:使用 setSpring.current[0].start() 而不是 setSpring()

    【讨论】:

      【解决方案2】:

      嗯,它适用于 react-spring v9.0.0 beta。

      【讨论】:

      • 这不是真的 - 我正在使用 react-spring v9.0.0 测试版并遇到完全相同的问题。
      猜你喜欢
      • 2020-08-16
      • 1970-01-01
      • 2021-11-18
      • 2021-05-05
      • 2018-12-26
      • 2018-12-27
      • 1970-01-01
      • 2020-02-15
      • 1970-01-01
      相关资源
      最近更新 更多