centau / vide

A reactive Luau library for creating UI.
https://centau.github.io/vide/
MIT License
95 stars 16 forks source link

Cannot create effect in non-reactive scope. #12

Closed gosulja closed 1 year ago

gosulja commented 1 year ago

I get this warning or error whenever I try and use **effect** in my return function for my component.

return function (props: {
    Title: string,
    Open: boolean,

    Position: UDim2,
})
    local panel
    local size = source(35)

    effect(function()
        if not panel then return end

        panel.Size = UDim2.fromOffset(250, size())
    end, size)

    panel = create "Frame" { ... }
littensy commented 1 year ago

Is your component being created within a root() or mount() call? A 'root scope' created by these functions needs to be present for functions like effect() to work.

gosulja commented 1 year ago

No it wasn't, I was having issues with mount. But I will try it

littensy commented 1 year ago

No it wasn't, I was having issues with mount. But I will try it

Did that get resolved?

gosulja commented 1 year ago

No it wasn't, I was having issues with mount. But I will try it

Did that get resolved?

It did, thanks!