Skip to content

Commit 67047d3

Browse files
committed
chore: cleaned up withnoderelease
1 parent 7bb089a commit 67047d3

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

apps/site/components/withNodeRelease.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,15 @@ type WithNodeReleaseProps = {
1414
// Note that Hooks cannot be used in a RSC async component
1515
// Async Components do not get re-rendered at all.
1616
const WithNodeRelease: FC<WithNodeReleaseProps> = async ({
17-
status,
17+
status: statuses,
1818
children: Component,
1919
}) => {
20-
const releaseData = await provideReleaseData();
21-
22-
let matchingRelease: NodeRelease | undefined;
23-
for (const statusItem of Array.isArray(status) ? status : [status]) {
24-
matchingRelease = releaseData.find(
25-
release => release.status === statusItem
26-
);
27-
if (matchingRelease) {
28-
break;
29-
}
30-
}
20+
const releases = await provideReleaseData();
21+
22+
const matchingRelease = [statuses]
23+
.flat()
24+
.map(status => releases.find(release => release.status === status))
25+
.find(Boolean);
3126

3227
if (matchingRelease) {
3328
return <Component release={matchingRelease} />;

0 commit comments

Comments
 (0)