roact icon indicating copy to clipboard operation
roact copied to clipboard

Tagging

Open AmaranthineCodices opened this issue 6 years ago • 1 comments

Lets you tag rendered Roact instances with Roact.Tag:

local function Test(props)
    return Roact.createElement("Frame", {
        BackgroundColor3 = props.backgroundColor,
        [Roact.Tag] = "Test"
    })
end

Currently needs lemur changes for unit tests to pass.

AmaranthineCodices avatar Mar 01 '19 22:03 AmaranthineCodices

@tiffany352 mentioned that it would be useful to assign multiple tags to the same instance.

We could accomplish that with a key like Roact.Event:

Roact.createElement("Frame", {
    [Roact.Tag.Foo] = true,
    [Roact.Tag.Bar] = true,
})

We would choose this over a list of tags because:

  • Diffing lists quickly is difficult
  • Creating an extra table per render is heavy
  • Accepting a string or list makes the API more confusing/complicated to implement

LPGhatguy avatar Nov 21 '19 22:11 LPGhatguy