I discovered jsx-slack v2 can use asynchronous component as following:
const AsyncComponent = async ({ userId }) => {
// Fetch some data
const name = await getUserName({ id: userId })
return <Section>Hello, {name}!</Section>
}
;(async () => {
console.log(
<Blocks>
<Context>Asynchronous component example</Context>
<Divider />
{await <AsyncComponent userId={123} />}
</Blocks>
)
})()
TypeScript requires to cast the component into any type.
This usage was found out by chance and it's out of our specification, but may have a worth to write down to the documentation as one of the useful way to use async functions.
I discovered jsx-slack v2 can use asynchronous component as following:
TypeScript requires to cast the component into
anytype.This usage was found out by chance and it's out of our specification, but may have a worth to write down to the documentation as one of the useful way to use async functions.