Roblox / roact

A view management library for Roblox Lua similar to React
https://roblox.github.io/roact
Apache License 2.0
558 stars 143 forks source link

attempt to call missing method '__mount' of table #386

Open krikora opened 1 year ago

krikora commented 1 year ago

I'm trying to make a button, but I'm getting this error: Roact.createReconciler:408: attempt to call missing method '__mount' of table. What am I doing wrong? Thanks.

My code:

local Flat = Roact.createElement("ExtendedButton")

function Flat:init()
    self.ref = Roact.createRef()
end

function Flat:render()
    local children = self.props.children

    return Roact.createElement("TextButton", {
        AutoButtonColor = false,
        Text = "",
        AutomaticSize = Enum.AutomaticSize.X,
        [Roact.Ref] = self.ref,
        BackgroundColor3 = Theme.colorScheme.primary,
        BorderSizePixel = 0,
        [Roact.Event.MouseButton1Click] = self.props.onClick or function() end
    }, {
        children,
        Roact.createElement(Ripple, {
            cornerRadius = UDim.new(0, 8)
        }),
        Roact.createElement("UICorner", {
            CornerRadius = UDim.new(0, 8)
        })
    })
end

function Flat:didMount()
    self.ref:getValue().Size = UDim2.fromOffset(self.ref:getValue().AbsoluteSize.X+80, 40)

    self.ref:getValue().AutomaticSize = false
end

In another script:

Roact.mount(
    Roact.createElement(Flat, {
        children = Button.Text("Hey")   
    }),
    script.Parent.Parent.Tree
)