You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error I'm getting is on the setIfTruthy(true, ChildBlocks()) call, and it reads Type 'SectionBuilder[]' is not assignable to type 'Undefinable<ViewBlockBuilder>'..
The issue seems to stem from the fact that the setIfTruthy conditional in ChildBlocks is returning an array of blocks.
If I update ChildBlocks to return one block instead, it works:
const ChildBlocks = () => [
Section().text('This is a child.'),
setIfTruthy(true, Section().text('This works')),
]
I've attempted wrapping the array in a BlockCollection, but that doesn't work, I believe because BlocksCollection builds its blocks.
Any tips on how to solve or work around this issue would be very much appreciated!
The text was updated successfully, but these errors were encountered:
I suppose a related question that is causing me to run into a similar type error is: How do you render an array of an array of blocks? For example:
const arrayOfNumbers = [1, 2, 3, 4, 5]
export const Home = () => {
return HomeTab()
.blocks(
Section().text('Hello world!'),
arrayOfNumbers.map((n) => [
// If I try to render an array of blocks here I get a type error.
])
)
.buildToObject()
}
First off, thank you @raycharius for building such an insanely useful library. Can't imagine life without it!
I'm running into a type error when I'm attempting to render a conditional within a conditional. Here's a minimal reproduction:
The error I'm getting is on the
setIfTruthy(true, ChildBlocks())
call, and it readsType 'SectionBuilder[]' is not assignable to type 'Undefinable<ViewBlockBuilder>'.
.The issue seems to stem from the fact that the
setIfTruthy
conditional inChildBlocks
is returning an array of blocks.If I update
ChildBlocks
to return one block instead, it works:I've attempted wrapping the array in a
BlockCollection
, but that doesn't work, I believe because BlocksCollection builds its blocks.Any tips on how to solve or work around this issue would be very much appreciated!
The text was updated successfully, but these errors were encountered: