chriscerie / roact-spring

A modern spring-physics based animation library for react-lua based on react-spring
https://www.chrisc.dev/roact-spring/
MIT License
63 stars 16 forks source link

Typescript, using Imperative API, Unsupported Type: Function (1.1.6) #50

Open BradenJ6164 opened 1 year ago

BradenJ6164 commented 1 year ago

When using imperative api, here is my implementation:

const [styleSpring, springApi] = useSpring(hooks, () => {
    return {
        rippleSize: new UDim2(),
    };
})

In my render:

    <frame
        Key="ripple"
        AnchorPoint={new Vector2(0.5, 0.5)}
        BackgroundColor3={Color3.fromRGB(255, 255, 255)}
        BackgroundTransparency={0.8}
        Position={new UDim2(0.5, 0, 0.5, 0)}
        Size={styleSpring.rippleSize}
    >

when activating the button:

MouseButton1Down: () =>
springApi.start({
    rippleSize: UDim2.fromScale(1, 1),                  
}),

When first joining, no errors happen and the components mount properly. Upon pressing the button, I get warnings in the console from promises. Here is the entire stack:

Unhandled Promise rejection:

-- Promise.Error(ExecutionError) --
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.helpers:22: Unsupported type: function
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.helpers:22 function getValuesFromType
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.Animation:12 function new
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.SpringValue:27 function new
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.Controller:41 function createSpring
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.Controller:56 function prepareKeys
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.Controller:101 function start
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.hooks.useSprings:132
ReplicatedStorage.rbxts_include.Promise:172 function runExecutor
ReplicatedStorage.rbxts_include.Promise:296

Promise created at:

ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.hooks.useSprings:131
ReplicatedStorage.TS.UserInterface.Components.Input.Buttons.BasicButton:30
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact.src.SingleEventManager:80

ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact-spring.src.hooks.useSprings:147
ReplicatedStorage.TS.UserInterface.Components.Input.Buttons.BasicButton:30
ReplicatedStorage.rbxts_include.node_modules.@rbxts.roact.src.SingleEventManager:80

Thanks!

BradenJ6164 commented 1 year ago

Edit: I found that installing an older version @1.1.3-ts.0, has fixed said issue.