This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
v1.1.0
This release fixes a minor reconciliation bug and introduces a new binding API, Roact.joinBindings
.
Changes Since 1.0.0
- Fixed an issue where updating a host element with children to an element with
nil
children caused the old children to not be unmounted. (#210) - Added
Roact.joinBindings
, which allows combining multiple bindings into a single binding that can be mapped. (#208)
Roact.joinBindings
The new joinBindings
API can be used to combine multiple bindings and use them to create a new binding!
You can use this to implement flexible sizing without going through the reconciler, for example:
local function Flex()
local aSize, setASize = Roact.createBinding(Vector2.new())
local bSize, setBSize = Roact.createBinding(Vector2.new())
return Roact.createElement("Frame", {
Size = Roact.joinBindings({aSize, bSize}):map(function(sizes)
local sum = Vector2.new()
for _, size in ipairs(sizes) do
sum = sum + size
end
return UDim2.new(0, sum.X, 0, sum.Y)
end),
}, {
A = Roact.createElement("Frame", {
Size = UDim2.new(1, 0, 0, 30),
[Roact.Change.AbsoluteSize] = function(instance)
setASize(instance.Size)
end,
}),
B = Roact.createElement("Frame", {
Size = UDim2.new(1, 0, 0, 30),
Position = aSize:map(function(size)
return UDim2.new(0, 0, 0, size.Y)
end),
[Roact.Change.AbsoluteSize] = function(instance)
setBSize(instance.Size)
end,
}),
})
end